class Helium::DataPoint
Attributes
port[R]
timestamp[R]
value[R]
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
# File lib/helium/data_point.rb, line 5 def initialize(opts = {}) super(opts) @timestamp = @params.dig("attributes", "timestamp") @value = @params.dig("attributes", "value") @port = @params.dig("attributes", "port") end
Public Instance Methods
aggregate?()
click to toggle source
# File lib/helium/data_point.rb, line 32 def aggregate? [max, min, avg].none? { |agg_value| agg_value.nil? } end
as_json()
click to toggle source
Calls superclass method
# File lib/helium/data_point.rb, line 36 def as_json j = super.merge({ timestamp: timestamp, port: port }) if aggregate? j[:max] = max j[:min] = min j[:avg] = avg else j[:value] = value end j end
avg()
click to toggle source
# File lib/helium/data_point.rb, line 27 def avg return nil unless @value.is_a?(Hash) @value["avg"] end
max()
click to toggle source
# File lib/helium/data_point.rb, line 17 def max return nil unless @value.is_a?(Hash) @value["max"] end
min()
click to toggle source
# File lib/helium/data_point.rb, line 22 def min return nil unless @value.is_a?(Hash) @value["min"] end