Class: Librevox::Protocol::Response
- Inherits:
-
Object
- Object
- Librevox::Protocol::Response
- Defined in:
- lib/librevox/protocol/response.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #api_response? ⇒ Boolean
- #command_reply? ⇒ Boolean
- #event ⇒ Object
- #event? ⇒ Boolean
-
#initialize(headers = "", content = "") ⇒ Response
constructor
A new instance of Response.
- #reply? ⇒ Boolean
Constructor Details
#initialize(headers = "", content = "") ⇒ Response
Returns a new instance of Response.
10 11 12 13 |
# File 'lib/librevox/protocol/response.rb', line 10 def initialize(headers = "", content = "") @headers = parse_headers(headers) @content = parse_content(content) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/librevox/protocol/response.rb', line 8 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/librevox/protocol/response.rb', line 8 def headers @headers end |
Instance Method Details
#api_response? ⇒ Boolean
23 24 25 |
# File 'lib/librevox/protocol/response.rb', line 23 def api_response? @headers[:content_type] == "api/response" end |
#command_reply? ⇒ Boolean
27 28 29 |
# File 'lib/librevox/protocol/response.rb', line 27 def command_reply? @headers[:content_type] == "command/reply" end |
#event ⇒ Object
19 20 21 |
# File 'lib/librevox/protocol/response.rb', line 19 def event @content[:event_name] if event? end |
#event? ⇒ Boolean
15 16 17 |
# File 'lib/librevox/protocol/response.rb', line 15 def event? @headers[:content_type] == "text/event-plain" end |
#reply? ⇒ Boolean
31 32 33 |
# File 'lib/librevox/protocol/response.rb', line 31 def reply? api_response? || command_reply? end |