Class: Tremolo::DataPoint
- Inherits:
-
Object
- Object
- Tremolo::DataPoint
- Defined in:
- lib/tremolo/data_point.rb
Instance Attribute Summary collapse
-
#series_name ⇒ Object
Returns the value of attribute series_name.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#time ⇒ Object
Returns the value of attribute time.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(series_name, data, time = nil) ⇒ DataPoint
constructor
A new instance of DataPoint.
-
#lines ⇒ Object
join lines for each value.
-
#measurement_and_tags ⇒ Object
join the series name and tag values.
-
#tag_values ⇒ Object
key/value pairs of tag data.
Constructor Details
#initialize(series_name, data, time = nil) ⇒ DataPoint
Returns a new instance of DataPoint.
5 6 7 8 9 10 11 |
# File 'lib/tremolo/data_point.rb', line 5 def initialize(series_name, data, time=nil) self.series_name = series_name self.time = time.nil? ? nil : time.to_i self. = data.fetch(:tags, {}) self.values = data.fetch(:values, []) end |
Instance Attribute Details
#series_name ⇒ Object
Returns the value of attribute series_name.
3 4 5 |
# File 'lib/tremolo/data_point.rb', line 3 def series_name @series_name end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/tremolo/data_point.rb', line 3 def @tags end |
#time ⇒ Object
Returns the value of attribute time.
3 4 5 |
# File 'lib/tremolo/data_point.rb', line 3 def time @time end |
#values ⇒ Object
Returns the value of attribute values.
3 4 5 |
# File 'lib/tremolo/data_point.rb', line 3 def values @values end |
Instance Method Details
#lines ⇒ Object
join lines for each value
24 25 26 |
# File 'lib/tremolo/data_point.rb', line 24 def lines values.map(&line_format).join("\n") end |
#measurement_and_tags ⇒ Object
join the series name and tag values
19 20 21 |
# File 'lib/tremolo/data_point.rb', line 19 def [series_name, tag_values].delete_if {|v| v.to_s.length == 0}.join(',') end |
#tag_values ⇒ Object
key/value pairs of tag data
14 15 16 |
# File 'lib/tremolo/data_point.rb', line 14 def tag_values .map(&value_mapper).join(',') end |