Class: Wavefront::Response::Highcharts
- Includes:
- JSON
- Defined in:
- lib/wavefront/response.rb
Instance Attribute Summary collapse
-
#highcharts ⇒ Object
readonly
Returns the value of attribute highcharts.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Highcharts
constructor
A new instance of Highcharts.
- #to_json ⇒ Object
Constructor Details
#initialize(response) ⇒ Highcharts
Returns a new instance of Highcharts.
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/wavefront/response.rb', line 73 def initialize(response) super @response = JSON.parse(response) @highcharts = [] self.timeseries.each do |series| # Highcharts expects the time in milliseconds since the epoch # And for some reason the first value tends to be BS @highcharts << { 'name' => series['label'], 'data' => series['data'][1..-1].map!{|x,y| [ x * 1000, y ]} } end end |
Instance Attribute Details
#highcharts ⇒ Object (readonly)
Returns the value of attribute highcharts.
71 72 73 |
# File 'lib/wavefront/response.rb', line 71 def highcharts @highcharts end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
71 72 73 |
# File 'lib/wavefront/response.rb', line 71 def response @response end |
Instance Method Details
#to_json ⇒ Object
87 88 89 |
# File 'lib/wavefront/response.rb', line 87 def to_json @highcharts.to_json end |