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(*args) ⇒ Cell

Returns a new instance of Cell.



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/google_visualr/data_table.rb', line 259

def initialize(*args)
  options = args.pop

  if options.is_a?(Hash)
    @v = options[:v]
    @f = options[:f]
    @p = options[:p]
  else
    @v = options
  end
end

Instance Attribute Details

#fObject

formatted



256
257
258
# File 'lib/google_visualr/data_table.rb', line 256

def f
  @f
end

#pObject

properties



257
258
259
# File 'lib/google_visualr/data_table.rb', line 257

def p
  @p
end

#vObject

value



255
256
257
# File 'lib/google_visualr/data_table.rb', line 255

def v
  @v
end

Instance Method Details

#to_jsObject



271
272
273
274
275
276
277
278
279
280
281
# File 'lib/google_visualr/data_table.rb', line 271

def to_js
  return "null" if @v.nil? && @f.nil? && @p.nil?

  js  = "{"
  js << "v: #{typecast(@v)}"
  js << ", f: #{typecast(@f)}"  unless @f.nil?
  js << ", p: #{typecast(@p)}"  unless @p.nil?
  js << "}"

  js
end