Class: Helium::SensorPackage

Inherits:
Resource show all
Defined in:
lib/helium/helium_script.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id, #params, #type

Instance Method Summary collapse

Methods inherited from Resource

#==, all, all_path, #as_json, create, #created_at, #destroy, #eql?, find, #hash, initialize_from_path, #metadata, resource_name, #resource_name, #resource_path, singleton, #to_json, #update, #updated_at

Methods included from Utils

#datetime_to_iso, #kebab_case

Constructor Details

#initialize(opts = {}) ⇒ SensorPackage

Returns a new instance of SensorPackage.



57
58
59
60
# File 'lib/helium/helium_script.rb', line 57

def initialize(opts = {})
  super(opts)
  @loaded = @params.dig('meta', 'loaded')
end

Instance Attribute Details

#loadedObject (readonly)

Returns the value of attribute loaded.



55
56
57
# File 'lib/helium/helium_script.rb', line 55

def loaded
  @loaded
end

Instance Method Details

#packageObject

Package is immutable and can be cached



68
69
70
71
# File 'lib/helium/helium_script.rb', line 68

def package
  @package ||= Package.initialize_from_path(path: "#{resource_path}/package",
                                            client: @client)
end

#sensorObject

Sensor is not immutable (name can change), and should not be cached



63
64
65
# File 'lib/helium/helium_script.rb', line 63

def sensor
  Sensor.initialize_from_path(path: "#{resource_path}/sensor", client: @client)
end