Class: GoogleVisualr::ColorFormat
- Defined in:
- lib/google_visualr/formatters.rb
Instance Attribute Summary collapse
-
#gradient_ranges ⇒ Object
Returns the value of attribute gradient_ranges.
-
#ranges ⇒ Object
Returns the value of attribute ranges.
Instance Method Summary collapse
- #add_gradient_range(from, to, color, fromBgColor, toBgColor) ⇒ Object
- #add_range(from, to, color, bgcolor) ⇒ Object
-
#initialize ⇒ ColorFormat
constructor
A new instance of ColorFormat.
- #to_js ⇒ Object
Methods inherited from Formatter
Methods included from ParamHelpers
#js_parameters, #stringify_keys!, #typecast
Constructor Details
#initialize ⇒ ColorFormat
Returns a new instance of ColorFormat.
47 48 49 50 |
# File 'lib/google_visualr/formatters.rb', line 47 def initialize @ranges = Array.new @gradient_ranges = Array.new end |
Instance Attribute Details
#gradient_ranges ⇒ Object
Returns the value of attribute gradient_ranges.
45 46 47 |
# File 'lib/google_visualr/formatters.rb', line 45 def gradient_ranges @gradient_ranges end |
#ranges ⇒ Object
Returns the value of attribute ranges.
44 45 46 |
# File 'lib/google_visualr/formatters.rb', line 44 def ranges @ranges end |
Instance Method Details
#add_gradient_range(from, to, color, fromBgColor, toBgColor) ⇒ Object
56 57 58 |
# File 'lib/google_visualr/formatters.rb', line 56 def add_gradient_range(from, to, color, fromBgColor, toBgColor) @gradient_ranges << { :from => from, :to => to, :color => color, :fromBgColor => fromBgColor, :toBgColor => toBgColor } end |
#add_range(from, to, color, bgcolor) ⇒ Object
52 53 54 |
# File 'lib/google_visualr/formatters.rb', line 52 def add_range(from, to, color, bgcolor) @ranges << { :from => from, :to => to, :color => color, :bgcolor => bgcolor } end |
#to_js ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/google_visualr/formatters.rb', line 60 def to_js super do |js| @ranges.each do |r| js << "\nformatter.addRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:bgcolor])});" end @gradient_ranges.each do |r| js << "\nformatter.addGradientRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:fromBgColor])}, #{typecast(r[:toBgColor])});" end end end |