Class: DeviceCloud::DataPoint
- Inherits:
-
Object
- Object
- DeviceCloud::DataPoint
- Defined in:
- lib/device_cloud/data_point.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
-
#id ⇒ Object
Returns the value of attribute id.
-
#server_timestamp ⇒ Object
Returns the value of attribute server_timestamp.
-
#stream_id ⇒ Object
Returns the value of attribute stream_id.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(element) ⇒ DataPoint
constructor
A new instance of DataPoint.
Constructor Details
#initialize(element) ⇒ DataPoint
Returns a new instance of DataPoint.
14 15 16 17 18 19 20 |
# File 'lib/device_cloud/data_point.rb', line 14 def initialize(element) @id = element.xpath("id").text @value = element.xpath("data").text @timestamp = Time.at(element.xpath("timestamp").text.to_f / 1000) @server_timestamp = Time.at(element.xpath("serverTimestamp").text.to_f / 1000) @stream_id = element.xpath("streamId").text end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def element @element end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def id @id end |
#server_timestamp ⇒ Object
Returns the value of attribute server_timestamp.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def @server_timestamp end |
#stream_id ⇒ Object
Returns the value of attribute stream_id.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def stream_id @stream_id end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def @timestamp end |
#value ⇒ Object
Returns the value of attribute value.
12 13 14 |
# File 'lib/device_cloud/data_point.rb', line 12 def value @value end |
Class Method Details
.parse(xml) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/device_cloud/data_point.rb', line 5 def self.parse(xml) result = Result.new(xml) result.document.xpath("//result/DataPoint").map do |data_point| DeviceCloud::DataPoint.new data_point end end |