Class: GroupList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ GroupList

Returns a new instance of GroupList.



6
7
8
9
10
# File 'lib/lights/grouplist.rb', line 6

def initialize(data = {})
  @groups = []
  data.each{|id,value| @groups << Group.new(id,value)} if data
  @data = data
end

Instance Attribute Details

#groupsObject (readonly)

Returns the value of attribute groups.



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

def groups
  @groups
end

Instance Method Details

#dataObject



12
13
14
15
16
# File 'lib/lights/grouplist.rb', line 12

def data
  data = @data
  @groups.each {|g| data[g.id] = g.data} if @groups
  data
end

#to_json(options = {}) ⇒ Object



18
19
20
# File 'lib/lights/grouplist.rb', line 18

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