Sha256: ac95a22963ce6bdf21c1e8f7fc56ff991d1f8c053f62f0bef59422ed0ba9c418
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Helium class Element < Resource attr_reader :name, :mac, :last_seen def initialize(opts = {}) super(opts) @name = @params.dig("attributes", "name") @mac = @params.dig("meta", "mac") @last_seen = @params.dig('meta', 'last-seen') end def sensors Collection.new(klass: Sensor, client: @client, belongs_to: self) end def device_configuration @client.element_device_configuration(self) end # @return [DateTime, nil] when the resource was last seen def last_seen return nil if @last_seen.nil? @_last_seen ||= DateTime.parse(@last_seen) end # TODO can probably generalize this a bit more def as_json super.merge({ name: name, mac: mac, last_seen: last_seen }) end def timeseries(opts = {}) size = opts.fetch(:size, 1000) port = opts.fetch(:port, nil) start_time = opts.fetch(:start_time, nil) end_time = opts.fetch(:end_time, nil) aggtype = opts.fetch(:aggtype, nil) aggsize = opts.fetch(:aggsize, nil) @client.element_timeseries(self, size: size, port: port, start_time: start_time, end_time: end_time, aggtype: aggtype, aggsize: aggsize ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
helium-ruby-0.22.0 | lib/helium/element.rb |
helium-ruby-0.21.0 | lib/helium/element.rb |