Class: Wavefront::Response::Highcharts

Inherits:
Ruby
  • Object
show all
Includes:
JSON
Defined in:
lib/wavefront/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#highchartsObject (readonly)

Returns the value of attribute highcharts.



71
72
73
# File 'lib/wavefront/response.rb', line 71

def highcharts
  @highcharts
end

#responseObject (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_jsonObject



87
88
89
# File 'lib/wavefront/response.rb', line 87

def to_json
  @highcharts.to_json
end