Class: GoogleVisualr::Formatter
- Inherits:
-
Object
- Object
- GoogleVisualr::Formatter
- Includes:
- ParamHelpers
- Defined in:
- lib/google_visualr/formatters.rb
Overview
Direct Known Subclasses
ArrowFormat, BarFormat, ColorFormat, DateFormat, NumberFormat
Instance Method Summary collapse
- #columns(*columns) ⇒ Object
-
#initialize(options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
- #options(*options) ⇒ Object
- #to_js {|js| ... } ⇒ Object
Methods included from ParamHelpers
#js_parameters, #stringify_keys!, #typecast
Constructor Details
#initialize(options = {}) ⇒ Formatter
Returns a new instance of Formatter.
7 8 9 |
# File 'lib/google_visualr/formatters.rb', line 7 def initialize(={}) @options = end |
Instance Method Details
#columns(*columns) ⇒ Object
12 13 14 |
# File 'lib/google_visualr/formatters.rb', line 12 def columns(*columns) @columns = columns.flatten end |
#options(*options) ⇒ Object
16 17 18 |
# File 'lib/google_visualr/formatters.rb', line 16 def (*) @options = stringify_keys!(.pop) end |
#to_js {|js| ... } ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/google_visualr/formatters.rb', line 20 def to_js(&block) js = "\nvar formatter = new google.visualization.#{self.class.to_s.split('::').last}(" js << js_parameters(@options) js << ");" yield js if block_given? @columns.each do |column| js << "\nformatter.format(data_table, #{column});" end js end |