Class: HelloGoodbye::Request
- Inherits:
-
Object
- Object
- HelloGoodbye::Request
- Defined in:
- lib/hello_goodbye/json/request.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#request_hash ⇒ Object
Returns the value of attribute request_hash.
Instance Method Summary collapse
-
#initialize(str) ⇒ Request
constructor
A new instance of Request.
- #request_data=(str) ⇒ Object
Constructor Details
#initialize(str) ⇒ Request
Returns a new instance of Request.
6 7 8 |
# File 'lib/hello_goodbye/json/request.rb', line 6 def initialize(str) self.request_data=str end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/hello_goodbye/json/request.rb', line 4 def command @command end |
#request_hash ⇒ Object
Returns the value of attribute request_hash.
3 4 5 |
# File 'lib/hello_goodbye/json/request.rb', line 3 def request_hash @request_hash end |
Instance Method Details
#request_data=(str) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/hello_goodbye/json/request.rb', line 10 def request_data=(str) @request_data = JSON.parse(str) unless @request_data.include?("command") raise ArgumentError, "The JSON string you supplied is invalid. All requests must include a 'command' attribute." end @command = @request_data["command"] @request_data end |