Class: Net::PTTH::Parser
- Inherits:
-
Object
- Object
- Net::PTTH::Parser
- Defined in:
- lib/net/ptth/parser.rb
Instance Attribute Summary collapse
-
#chunk ⇒ Object
readonly
Returns the value of attribute chunk.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#add(data) ⇒ Object
(also: #<<)
Public: Adds data to be parsed.
-
#body ⇒ Object
Public: Access the body of the string being parsed.
- #body=(chunk) ⇒ Object
-
#finished? ⇒ Boolean
Public: Internal flag access to know when parsing ended.
-
#http_method ⇒ Object
Public: Gets the http method parsed.
-
#http_version ⇒ Object
Public: Gets the http version parsed.
-
#initialize ⇒ Parser
constructor
Public: Contructor.
-
#on_headers_complete(headers) ⇒ Object
Protected: Sets the headers when the parser completes.
- #on_message_begin ⇒ Object
-
#on_message_complete ⇒ Object
Protected: Flags the parsing as ended.
-
#reset ⇒ Object
Public: Resets the parser internal flags.
-
#status_code ⇒ Object
Public: Gets the status code parsed.
-
#upgrade? ⇒ Boolean
Public: Check for an upgrade header in the parsed string.
-
#url ⇒ Object
Public: Gets the url parsed.
Constructor Details
#initialize ⇒ Parser
Public: Contructor
9 10 11 12 |
# File 'lib/net/ptth/parser.rb', line 9 def initialize @parser = Http::Parser.new(self) reset end |
Instance Attribute Details
#chunk ⇒ Object (readonly)
Returns the value of attribute chunk.
5 6 7 |
# File 'lib/net/ptth/parser.rb', line 5 def chunk @chunk end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/net/ptth/parser.rb', line 5 def headers @headers end |
Instance Method Details
#add(data) ⇒ Object Also known as: <<
Public: Adds data to be parsed.
data: string to be parsed
18 19 20 |
# File 'lib/net/ptth/parser.rb', line 18 def add(data) @parser << data end |
#body ⇒ Object
Public: Access the body of the string being parsed
67 68 69 |
# File 'lib/net/ptth/parser.rb', line 67 def body @chunk end |
#body=(chunk) ⇒ Object
71 72 73 |
# File 'lib/net/ptth/parser.rb', line 71 def body=(chunk) @chunk << chunk end |
#finished? ⇒ Boolean
Public: Internal flag access to know when parsing ended
55 |
# File 'lib/net/ptth/parser.rb', line 55 def finished?; @finished; end |
#http_method ⇒ Object
Public: Gets the http method parsed
31 32 33 |
# File 'lib/net/ptth/parser.rb', line 31 def http_method @parser.http_method end |
#http_version ⇒ Object
Public: Gets the http version parsed
37 38 39 |
# File 'lib/net/ptth/parser.rb', line 37 def http_version @parser.http_version end |
#on_headers_complete(headers) ⇒ Object
Protected: Sets the headers when the parser completes.
77 78 79 |
# File 'lib/net/ptth/parser.rb', line 77 def on_headers_complete(headers) @headers = headers end |
#on_message_begin ⇒ Object
81 82 83 |
# File 'lib/net/ptth/parser.rb', line 81 def reset end |
#on_message_complete ⇒ Object
Protected: Flags the parsing as ended
87 88 89 |
# File 'lib/net/ptth/parser.rb', line 87 def @finished = true end |
#reset ⇒ Object
Public: Resets the parser internal flags
59 60 61 62 63 |
# File 'lib/net/ptth/parser.rb', line 59 def reset @finished = false @headers = nil @chunk = "" end |
#status_code ⇒ Object
Public: Gets the status code parsed
43 44 45 |
# File 'lib/net/ptth/parser.rb', line 43 def status_code @parser.status_code end |
#upgrade? ⇒ Boolean
Public: Check for an upgrade header in the parsed string
25 26 27 |
# File 'lib/net/ptth/parser.rb', line 25 def upgrade? @parser.upgrade? end |
#url ⇒ Object
Public: Gets the url parsed
49 50 51 |
# File 'lib/net/ptth/parser.rb', line 49 def url @parser.request_url end |