Class: GoogleVisualr::DataTable::Cell

Inherits:
Object
  • Object
show all
Includes:
ParamHelpers
Defined in:
lib/google_visualr/data_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options, type = nil)
  if options.is_a?(Hash)
    @v = options[:v]
    @f = options[:f]
    @p = options[:p]
    @type = type
  else # should be a string
    @v = options
    @type = type
  end
end

Instance Attribute Details

#fObject

formatted



263
264
265
# File 'lib/google_visualr/data_table.rb', line 263

def f
  @f
end

#pObject

properties



264
265
266
# File 'lib/google_visualr/data_table.rb', line 264

def p
  @p
end

#vObject

value



262
263
264
# File 'lib/google_visualr/data_table.rb', line 262

def v
  @v
end

Instance Method Details

#to_jsObject



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