Class: SensorState

Inherits:
HObject show all
Defined in:
lib/lights/sensor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HObject

#to_json

Constructor Details

#initialize(data) ⇒ SensorState

Returns a new instance of SensorState.



3
4
5
6
7
# File 'lib/lights/sensor.rb', line 3

def initialize(data)
  @last_updated = data["lastupdated"]
  @daylight = data["daylight"]
  @button_event = data["buttonevent"]
end

Instance Attribute Details

#last_updatedObject (readonly)

Returns the value of attribute last_updated.



2
3
4
# File 'lib/lights/sensor.rb', line 2

def last_updated
  @last_updated
end

Instance Method Details

#dataObject



9
10
11
12
13
14
15
# File 'lib/lights/sensor.rb', line 9

def data
  data = {}
  data["lastupdated"] = @last_updated if @last_updated
  data["daylight"] = @daylight unless @daylight.nil?
  data["buttonevent"] = @button_event if @button_event
  data
end