Class: Bulb

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Bulb.



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

def initialize(id,data = {})
  @id = id
  @name = data["name"]
  @type = data["type"]
  @swversion = data["type"]
  @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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#swversionObject (readonly)

Returns the value of attribute swversion.



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

def swversion
  @swversion
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#dataObject



16
17
18
19
20
21
22
23
# File 'lib/lights/bulb.rb', line 16

def data
  data = {}
  data["name"] = @name if @name
  data["type"] = @type if @type
  data["swversion"] = @swversion if @swversion
  data["state"] = @state.data if !@state.data.empty?
  data
end