Class: InfluxDB::PointValue
- Inherits:
-
Object
- Object
- InfluxDB::PointValue
- Defined in:
- lib/influxdb/point_value.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(value) ⇒ PointValue
constructor
A new instance of PointValue.
- #load ⇒ Object
- #maybe_json? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ PointValue
Returns a new instance of PointValue.
8 9 10 |
# File 'lib/influxdb/point_value.rb', line 8 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/influxdb/point_value.rb', line 6 def value @value end |
Instance Method Details
#dump ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/influxdb/point_value.rb', line 12 def dump if value.is_a?(Array) || value.is_a?(Hash) JSON.generate(value) else value end end |
#load ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/influxdb/point_value.rb', line 20 def load if maybe_json? begin JSON.parse(value) rescue JSON::ParserError => e value end else value end end |
#maybe_json? ⇒ Boolean
32 33 34 |
# File 'lib/influxdb/point_value.rb', line 32 def maybe_json? value.is_a?(String) && value =~ /\A(\{|\[).*(\}|\])$/ end |