Module: Chartism::Chart::ClassMethods
- Included in:
- Line::ClassMethods, Pie::ClassMethods
- Defined in:
- lib/chartism/chart.rb
Instance Method Summary collapse
- #define_array_option(method_name) ⇒ Object
- #define_block_option(method_name, default = nil) ⇒ Object
- #define_option(method_name) ⇒ Object
Instance Method Details
#define_array_option(method_name) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chartism/chart.rb', line 43 def define_array_option method_name define_method method_name do |value=nil, &block| array = instance_variable_get "@#{method_name}" array = instance_variable_set("@#{method_name}", []) unless array array << value unless value.nil? array << block if block array end end |
#define_block_option(method_name, default = nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/chartism/chart.rb', line 36 def define_block_option method_name, default=nil define_method method_name do |&block| instance_variable_set "@#{method_name}", block if block instance_variable_get("@#{method_name}") || default end end |
#define_option(method_name) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/chartism/chart.rb', line 28 def define_option method_name define_method method_name do |value=nil, &block| instance_variable_set "@#{method_name}", value unless value.nil? instance_variable_set "@#{method_name}", block if block instance_variable_get "@#{method_name}" end end |