Class: RTransmission::Response
- Inherits:
-
Object
- Object
- RTransmission::Response
- Defined in:
- lib/rtransmission/response.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#body ⇒ Object
Returns the value of attribute body.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize(body, prefix, block) ⇒ Response
constructor
A new instance of Response.
- #parse ⇒ Object
Constructor Details
#initialize(body, prefix, block) ⇒ Response
Returns a new instance of Response.
13 14 15 16 17 |
# File 'lib/rtransmission/response.rb', line 13 def initialize(body, prefix, block) @body = body @prefix = prefix @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
11 12 13 |
# File 'lib/rtransmission/response.rb', line 11 def block @block end |
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/rtransmission/response.rb', line 9 def body @body end |
#prefix ⇒ Object
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/rtransmission/response.rb', line 10 def prefix @prefix end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rtransmission/response.rb', line 19 def parse body = JSON.parse(@body) raise RTransmission::Exception.new((@prefix ? @prefix + ': ' : '') + body['result']) if body['result'] != 'success' return @block.call(body['arguments']) if @block body['arguments'] end |