Class: DeviceCloud::DataStream
- Inherits:
-
Object
- Object
- DeviceCloud::DataStream
- Defined in:
- lib/device_cloud/data_stream.rb
Constant Summary collapse
- RESOURCE_PATH =
'/ws/DataStream'
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
Class Method Summary collapse
Instance Method Summary collapse
- #current_id ⇒ Object
- #delete(client) ⇒ Object
- #device_id ⇒ Object
- #device_path ⇒ Object
-
#initialize(element) ⇒ DataStream
constructor
A new instance of DataStream.
- #mac ⇒ Object
- #name ⇒ Object
- #path ⇒ Object
- #stream_id ⇒ Object
- #timestamp ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(element) ⇒ DataStream
Returns a new instance of DataStream.
15 16 17 |
# File 'lib/device_cloud/data_stream.rb', line 15 def initialize(element) @element = element end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
13 14 15 |
# File 'lib/device_cloud/data_stream.rb', line 13 def element @element end |
Class Method Details
.parse(xml) ⇒ Object
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#current_id ⇒ Object
31 32 33 |
# File 'lib/device_cloud/data_stream.rb', line 31 def current_id current.id end |
#delete(client) ⇒ Object
19 20 21 |
# File 'lib/device_cloud/data_stream.rb', line 19 def delete(client) client.delete RESOURCE_PATH + "/" + stream_id end |
#device_id ⇒ Object
39 40 41 |
# File 'lib/device_cloud/data_stream.rb', line 39 def device_id stream_id_parse[1] end |
#device_path ⇒ Object
55 56 57 |
# 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 ⇒ Object
43 44 45 |
# File 'lib/device_cloud/data_stream.rb', line 43 def mac path.to_i(16) end |
#name ⇒ Object
51 52 53 |
# File 'lib/device_cloud/data_stream.rb', line 51 def name stream_id_parse[3] end |
#path ⇒ Object
47 48 49 |
# File 'lib/device_cloud/data_stream.rb', line 47 def path stream_id_parse[2] end |
#stream_id ⇒ Object
35 36 37 |
# File 'lib/device_cloud/data_stream.rb', line 35 def stream_id element.xpath("streamId").text end |
#timestamp ⇒ Object
27 28 29 |
# File 'lib/device_cloud/data_stream.rb', line 27 def current. end |
#value ⇒ Object
23 24 25 |
# File 'lib/device_cloud/data_stream.rb', line 23 def value current.value end |