class DeviceCloud::DataPoint

Attributes

element[RW]
id[RW]
server_timestamp[RW]
stream_id[RW]
timestamp[RW]
value[RW]

Public Class Methods

new(element) click to toggle source
# 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
parse(xml) click to toggle source
# 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