Class: Grid::Command
- Inherits:
-
Object
- Object
- Grid::Command
- Defined in:
- lib/grid/command.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(name, params) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(name, params) ⇒ Command
Returns a new instance of Command.
7 8 9 |
# File 'lib/grid/command.rb', line 7 def initialize(name, params) @name, @params = name, params end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/grid/command.rb', line 5 def name @name end |
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/grid/command.rb', line 5 def params @params end |
Class Method Details
.parse(body) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/grid/command.rb', line 11 def self.parse(body) return if body == '' data = JSON.parse(body) cmd = Command.new( data['name'].to_sym, data['params'] ) cmd end |
Instance Method Details
#encode ⇒ Object
24 25 26 27 28 29 |
# File 'lib/grid/command.rb', line 24 def encode JSON.unparse( :name => @name, :params => @params ) end |