Class: Command
- Inherits:
-
Object
- Object
- Command
- Defined in:
- lib/lights/command.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(data = {}) ⇒ Command
constructor
A new instance of Command.
- #to_json(options = {}) ⇒ Object
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
#address ⇒ Object (readonly)
Returns the value of attribute address.
2 3 4 |
# File 'lib/lights/command.rb', line 2 def address @address end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
2 3 4 |
# File 'lib/lights/command.rb', line 2 def body @body end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
2 3 4 |
# File 'lib/lights/command.rb', line 2 def method @method end |
Instance Method Details
#data ⇒ Object
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(={}) data.to_json end |