Object
Themes serves as a point of interaction between the user and the underlying collection of themes made available to Prawn::Graph.
Adds the theme defined by the yaml file specified to the mapping of registered themes stored in +@@_themes_list+. Converts the YAML object into a Theme object for use in the application.
# File lib/prawn/graph/themes.rb, line 29 def self._register_theme(theme_file_path) theme = Theme.new(YAML.load(IO.read(File.expand_path(theme_file_path)))) if !defined? @@_themes_list @@_themes_list = {} end @@_themes_list[theme.name.to_sym] = theme end
Called once when Prawn::Graph is loaded, initializes the list of themes currently bundled. If you have your own custom theme you’d like to use instead, use _register_theme and give it the path to your theme file.
# File lib/prawn/graph/themes.rb, line 16 def self.initialize_themes path = File.expand_path(File.dirname(__FILE__) + '/themes/') Dir.open(path) do |dir| dir.each do |file| _register_theme(path + '/' + file) if file.include?('.yml') end end end
Hook into method_missing to allow us to do things like:
Prawn::Chart::Themes.theme_name
To return the theme object being looked for.
# File lib/prawn/graph/themes.rb, line 49 def self.method_missing(method, *args) if @@_themes_list.keys.include?(method) return @@_themes_list[method] end end
Generated with the Darkfish Rdoc Generator 2.