Sha256: d421f05fc70e4fe703199d3d92a051e1b272e2aaa0908e64acc974e3d588c260
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
module Helium class Sensor < Resource attr_reader :name, :mac, :ports, :last_seen def initialize(opts = {}) super(opts) @name = @params.dig('attributes', 'name') @mac = @params.dig('meta', 'mac') @ports = @params.dig('meta', 'ports') @last_seen = @params.dig('meta', 'last-seen') end def element @client.sensor_element(self) end def self.all_path "/sensor?include=label" end def labels @client.sensor_labels(self) 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.sensor_timeseries(self, size: size, port: port, start_time: start_time, end_time: end_time, aggtype: aggtype, aggsize: aggsize ) 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, ports: ports, last_seen: last_seen }) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
helium-ruby-0.17.0 | lib/helium/sensor.rb |
helium-ruby-0.16.0 | lib/helium/sensor.rb |
helium-ruby-0.15.0 | lib/helium/sensor.rb |
helium-ruby-0.14.0 | lib/helium/sensor.rb |