Class: GrowthForecast::Complex::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/growthforecast/complex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Item

Returns a new instance of Item.



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/growthforecast/complex.rb', line 57

def initialize(obj)
  if obj.is_a?(String)
    obj = JSON.parse(obj)
  end
  obj.keys.each do |k|
    obj[k.to_sym] = obj.delete(k)
  end

  @graph_id = obj[:graph_id]
  @gmode = obj[:gmode] || 'gauge'
  @stack = (obj[:stack] || obj[:stack].nil?) ? true : false
  @type = obj[:type] || 'AREA'
end

Instance Attribute Details

#gmodeObject

Returns the value of attribute gmode.



55
56
57
# File 'lib/growthforecast/complex.rb', line 55

def gmode
  @gmode
end

#graph_idObject

Returns the value of attribute graph_id.



55
56
57
# File 'lib/growthforecast/complex.rb', line 55

def graph_id
  @graph_id
end

#stackObject

Returns the value of attribute stack.



55
56
57
# File 'lib/growthforecast/complex.rb', line 55

def stack
  @stack
end

#typeObject

Returns the value of attribute type.



55
56
57
# File 'lib/growthforecast/complex.rb', line 55

def type
  @type
end

Instance Method Details

#to_hashObject



71
72
73
# File 'lib/growthforecast/complex.rb', line 71

def to_hash
  {'graph_id' => @graph_id, 'gmode' => @gmode, 'stack' => @stack, 'type' => @type}
end