Class: GoogleVisualr::DataTable::Cell
- Inherits:
-
Object
- Object
- GoogleVisualr::DataTable::Cell
- Includes:
- ParamHelpers
- Defined in:
- lib/google_visualr/data_table.rb
Instance Attribute Summary collapse
-
#f ⇒ Object
formatted.
-
#p ⇒ Object
properties.
-
#v ⇒ Object
value.
Instance Method Summary collapse
-
#initialize(options, type = nil) ⇒ Cell
constructor
A new instance of Cell.
- #to_js ⇒ Object
Methods included from ParamHelpers
#js_parameters, #stringify_keys!, #typecast
Constructor Details
#initialize(options, type = nil) ⇒ Cell
Returns a new instance of Cell.
266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/google_visualr/data_table.rb', line 266 def initialize(, type = nil) if .is_a?(Hash) @v = [:v] @f = [:f] @p = [:p] @type = type else # should be a string @v = @type = type end end |
Instance Attribute Details
#f ⇒ Object
formatted
263 264 265 |
# File 'lib/google_visualr/data_table.rb', line 263 def f @f end |
#p ⇒ Object
properties
264 265 266 |
# File 'lib/google_visualr/data_table.rb', line 264 def p @p end |
#v ⇒ Object
value
262 263 264 |
# File 'lib/google_visualr/data_table.rb', line 262 def v @v end |
Instance Method Details
#to_js ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/google_visualr/data_table.rb', line 278 def to_js return "null" if @v.nil? && @f.nil? && @p.nil? js = "{" js << "v: #{typecast(@v, @type)}" js << ", f: #{typecast(@f)}" unless @f.nil? js << ", p: #{typecast(@p)}" unless @p.nil? js << "}" js end |