Class: HueConfig

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ HueConfig

Returns a new instance of HueConfig.



7
8
9
10
11
12
# File 'lib/lights/config.rb', line 7

def initialize(data = {})
  @name = data["name"]
  @swversion = data["swversion"]
  @whitelist = UserList.new(data["whitelist"])
  @data = data
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#swversionObject (readonly)

Returns the value of attribute swversion.



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

def swversion
  @swversion
end

#whitelistObject (readonly)

Returns the value of attribute whitelist.



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

def whitelist
  @whitelist
end

Instance Method Details

#dataObject



14
15
16
17
18
19
20
# File 'lib/lights/config.rb', line 14

def data
  data = @data
  data["name"] = @name if @name
  data["swversion"] = @swversion if @swversion
  data["whitelist"] = @whitelist.data if !@whitelist.data.empty?
  data
end

#to_json(options = {}) ⇒ Object



22
23
24
# File 'lib/lights/config.rb', line 22

def to_json(options={})
  data.to_json
end