Class: Librevox::Protocol::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/librevox/protocol/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/librevox/protocol/response.rb', line 8

def content
  @content
end

#headersObject (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

Returns:

  • (Boolean)


23
24
25
# File 'lib/librevox/protocol/response.rb', line 23

def api_response?
  @headers[:content_type] == "api/response"
end

#command_reply?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/librevox/protocol/response.rb', line 27

def command_reply?
  @headers[:content_type] == "command/reply"
end

#eventObject



19
20
21
# File 'lib/librevox/protocol/response.rb', line 19

def event
  @content[:event_name] if event?
end

#event?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/librevox/protocol/response.rb', line 15

def event?
  @headers[:content_type] == "text/event-plain"
end

#reply?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/librevox/protocol/response.rb', line 31

def reply?
  api_response? || command_reply?
end