Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/tunnels/parser.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #on_complete ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
6 7 8 9 |
# File 'lib/tunnels/parser.rb', line 6 def initialize @parser = Http::Parser.new @raw = '' end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/tunnels/parser.rb', line 4 def raw @raw end |
Instance Method Details
#<<(data) ⇒ Object
11 12 13 14 |
# File 'lib/tunnels/parser.rb', line 11 def << data @raw << data @parser << data end |
#on_complete ⇒ Object
16 17 18 19 20 21 |
# File 'lib/tunnels/parser.rb', line 16 def on_complete @parser. = proc do yield @raw reset end end |
#reset ⇒ Object
23 24 25 26 |
# File 'lib/tunnels/parser.rb', line 23 def reset @parser.reset! @raw.respond_to?(:clear) ? @raw.clear : @raw = '' end |