Class: Command

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Command

Returns a new instance of Command.



3
4
5
6
7
8
# File 'lib/lights/command.rb', line 3

def initialize(data = {})
  @address = data["address"]
  @body = data["body"]
  @method = data["method"]
  @data = data
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



2
3
4
# File 'lib/lights/command.rb', line 2

def address
  @address
end

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'lib/lights/command.rb', line 2

def body
  @body
end

#methodObject (readonly)

Returns the value of attribute method.



2
3
4
# File 'lib/lights/command.rb', line 2

def method
  @method
end

Instance Method Details

#dataObject



10
11
12
13
14
15
16
# File 'lib/lights/command.rb', line 10

def data
  data = @data
  data["address"] = @address if @address
  data["body"] = @body if @body
  data["method"] = @method if @method
  data
end

#to_json(options = {}) ⇒ Object



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

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