Class: Schedule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Schedule.



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

def initialize(id,data = {})
  @id = id
  @name = data["name"]
  @time = data["time"]
  @status = data["status"]
  @command = Command.new(data["command"])
  @data = data
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/lights/schedule.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/lights/schedule.rb', line 4

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/lights/schedule.rb', line 4

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



4
5
6
# File 'lib/lights/schedule.rb', line 4

def time
  @time
end

Instance Method Details

#dataObject



18
19
20
21
22
23
24
25
# File 'lib/lights/schedule.rb', line 18

def data
  data = @data
  data["name"] = @name if @name
  data["time"] = @time if @time
  data["status"] = @status if @status
  data["command"] = @command.data if !@command.data.empty?
  data
end

#sceneObject



14
15
16
# File 'lib/lights/schedule.rb', line 14

def scene
  @command.body["scene"]
end

#to_json(options = {}) ⇒ Object



27
28
29
# File 'lib/lights/schedule.rb', line 27

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