Class: ScheduleList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ ScheduleList

Returns a new instance of ScheduleList.



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

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

Instance Attribute Details

#schedulesObject (readonly)

Returns the value of attribute schedules.



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

def schedules
  @schedules
end

Instance Method Details

#dataObject



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

def data
  data = @data
  @schedules.each {|s| data[s.id] = s.data} if @schedules
  data
end

#to_json(options = {}) ⇒ Object



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

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