Class: RubyRabbitmqJanus::Janus::Responses::Response
- Inherits:
-
Object
- Object
- RubyRabbitmqJanus::Janus::Responses::Response
- Defined in:
- lib/rrj/janus/responses/response.rb
Overview
# Read and parse a response to janus.
Read a message in rabbitmq queue. This message is formatted to JSON or Hash format. For developpment it’s possible to used a ‘nice` JSON.
Direct Known Subclasses
Instance Method Summary collapse
-
#error_code ⇒ Object
Return request error code.
-
#error_reason ⇒ Object
Return request error reason.
-
#initialize(response_janus) ⇒ Response
constructor
Instantiate a response.
-
#janus ⇒ Object
Read field Janus in response message.
-
#to_hash ⇒ Hash
Return request to hash format.
-
#to_json(*_args) ⇒ String
Return request to json format.
-
#to_nice_json ⇒ String
Return request to json format with nice format.
Constructor Details
#initialize(response_janus) ⇒ Response
Instantiate a response
19 20 21 22 23 24 |
# File 'lib/rrj/janus/responses/response.rb', line 19 def initialize(response_janus) @request = response_janus errors if error? bad_request if bad_request? end |
Instance Method Details
#error_code ⇒ Object
Return request error code
@return [Integer] Code error
50 51 52 |
# File 'lib/rrj/janus/responses/response.rb', line 50 def error_code @request['error']['code'].to_i end |
#error_reason ⇒ Object
Return request error reason
@return [String] Reason error
57 58 59 |
# File 'lib/rrj/janus/responses/response.rb', line 57 def error_reason @request['error']['reason'] end |
#janus ⇒ Object
Read field Janus in response message
62 63 64 |
# File 'lib/rrj/janus/responses/response.rb', line 62 def janus request['janus'] end |
#to_hash ⇒ Hash
Return request to hash format
43 44 45 |
# File 'lib/rrj/janus/responses/response.rb', line 43 def to_hash @request end |
#to_json(*_args) ⇒ String
Return request to json format
29 30 31 |
# File 'lib/rrj/janus/responses/response.rb', line 29 def to_json(*_args) @request.to_json end |
#to_nice_json ⇒ String
Return request to json format with nice format
36 37 38 |
# File 'lib/rrj/janus/responses/response.rb', line 36 def to_nice_json JSON.pretty_generate to_hash end |