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? ⇒ Boolean
Test if response it’s an error.
-
#initialize(response_janus) ⇒ Response
constructor
Instantiate a response.
-
#to_hash ⇒ Hash
Return request to hash format.
-
#to_json ⇒ 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 |
# File 'lib/rrj/janus/responses/response.rb', line 19 def initialize(response_janus) @request = response_janus rescue raise Errors::Janus::Response::Initializer end |
Instance Method Details
#error? ⇒ Boolean
Test if response it’s an error
55 56 57 |
# File 'lib/rrj/janus/responses/response.rb', line 55 def error? @request['janus'].match?('error') end |
#to_hash ⇒ Hash
Return request to hash format
46 47 48 49 50 |
# File 'lib/rrj/janus/responses/response.rb', line 46 def to_hash @request rescue raise Errors::Janus::Response::ToHash end |
#to_json ⇒ String
Return request to json format
28 29 30 31 32 |
# File 'lib/rrj/janus/responses/response.rb', line 28 def to_json @request.to_json rescue raise Errors::Janus::Response::ToJson end |
#to_nice_json ⇒ String
Return request to json format with nice format
37 38 39 40 41 |
# File 'lib/rrj/janus/responses/response.rb', line 37 def to_nice_json JSON.pretty_generate to_hash rescue raise Errors::Janus::Response::ToNiceJson end |