class DeviceCloud::DataStream

Constants

RESOURCE_PATH

Attributes

element[RW]

Public Class Methods

new(element) click to toggle source
# File lib/device_cloud/data_stream.rb, line 15
def initialize(element)
  @element = element
end
parse(xml) click to toggle source
# File lib/device_cloud/data_stream.rb, line 6
def self.parse(xml)
  result = Result.new(xml)
  result.document.xpath("//result/DataStream").map do |stream|
    DeviceCloud::DataStream.new stream
  end
end

Public Instance Methods

current_id() click to toggle source
# File lib/device_cloud/data_stream.rb, line 31
def current_id
  current.id
end
delete(client) click to toggle source
# File lib/device_cloud/data_stream.rb, line 19
def delete(client)
  client.delete RESOURCE_PATH + "/" + stream_id
end
device_id() click to toggle source
# File lib/device_cloud/data_stream.rb, line 39
def device_id
  stream_id_parse[1]
end
device_path() click to toggle source
# File lib/device_cloud/data_stream.rb, line 55
def device_path
  "dia/channel/#{device_id}/#{mac.to_s(16).rjust(16,"0")}/"
end
mac() click to toggle source
# File lib/device_cloud/data_stream.rb, line 43
def mac
  path.to_i(16)
end
name() click to toggle source
# File lib/device_cloud/data_stream.rb, line 51
def name
  stream_id_parse[3]
end
path() click to toggle source
# File lib/device_cloud/data_stream.rb, line 47
def path
  stream_id_parse[2]
end
stream_id() click to toggle source
# File lib/device_cloud/data_stream.rb, line 35
def stream_id
  element.xpath("streamId").text
end
timestamp() click to toggle source
# File lib/device_cloud/data_stream.rb, line 27
def timestamp
  current.timestamp
end
value() click to toggle source
# File lib/device_cloud/data_stream.rb, line 23
def value
  current.value
end

Private Instance Methods

current() click to toggle source
# File lib/device_cloud/data_stream.rb, line 65
def current
  DataPoint.new(element.xpath("currentValue"))
end
stream_id_parse() click to toggle source
# File lib/device_cloud/data_stream.rb, line 61
def stream_id_parse
  /dia\/channel\/((?:[0-9a-fA-F]{8}-?){4})\/([^\/]*)\/([a-z_]*)/.match stream_id
end