Class: Schedule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HObject

#to_json

Constructor Details

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

Returns a new instance of Schedule.



8
9
10
11
12
13
14
15
16
17
# File 'lib/lights/schedule.rb', line 8

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

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

#createdObject (readonly)

Returns the value of attribute created.



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

def created
  @created
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#local_timeObject (readonly)

Returns the value of attribute local_time.



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

def local_time
  @local_time
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#dataObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lights/schedule.rb', line 23

def data
  data = {}
  data["name"] = @name if @name
  data["time"] = @time if @time
  data["status"] = @status if @status
  data["description"] = @description if @description
  data["localtime"] = @local_time if @local_time
  data["created"] = @created if @created
  data["command"] = @command.data unless @command.data.empty?
  data
end

#sceneObject



19
20
21
# File 'lib/lights/schedule.rb', line 19

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