Class: Bulb

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HObject

#to_json

Constructor Details

#initialize(id, data = {}) ⇒ Bulb

Returns a new instance of Bulb.



8
9
10
11
12
13
14
15
16
17
# File 'lib/lights/bulb.rb', line 8

def initialize(id,data = {})
  @id = id
  @name = data["name"]
  @type = data["type"]
  @sw_version = data["swversion"]
  @point_symbol = data["pointsymbol"]
  @model_id = data["modelid"]
  @unique_id = data["uniqueid"]
  @state = BulbState.new data["state"]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def id
  @id
end

#model_idObject (readonly)

Returns the value of attribute model_id.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def model_id
  @model_id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def name
  @name
end

#point_symbolObject (readonly)

Returns the value of attribute point_symbol.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def point_symbol
  @point_symbol
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def state
  @state
end

#sw_versionObject (readonly)

Returns the value of attribute sw_version.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def sw_version
  @sw_version
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def type
  @type
end

#unique_idObject (readonly)

Returns the value of attribute unique_id.



5
6
7
# File 'lib/lights/bulb.rb', line 5

def unique_id
  @unique_id
end

Instance Method Details

#dataObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lights/bulb.rb', line 19

def data
  data = {}
  data["name"] = @name if @name
  data["type"] = @type if @type
  data["swversion"] = @sw_version if @sw_version
  data["state"] = @state.data unless @state.data.empty?
  data["pointsymbol"] = @point_symbol if @point_symbol
  data["modelid"] = @model_id if @model_id
  data["uniqueid"] = @unique_id if @unique_id
  data
end