Class: EM::Tycoon::Protocol::Parser
- Inherits:
-
Object
- Object
- EM::Tycoon::Protocol::Parser
- Includes:
- Deferrable
- Defined in:
- lib/em/tycoon/protocol/parser.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#bytes_parsed ⇒ Object
readonly
Returns the value of attribute bytes_parsed.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(timeout = 0) ⇒ Parser
constructor
Create a new Parser deferrable, using the specified initial data and optional timeout specified in seconds.
- #parse_chunk(data) ⇒ Object
Constructor Details
#initialize(timeout = 0) ⇒ Parser
Create a new Parser deferrable, using the specified initial data and optional timeout specified in seconds
12 13 14 15 16 |
# File 'lib/em/tycoon/protocol/parser.rb', line 12 def initialize(timeout=0) @bytes_parsed = 0 timeout(timeout) if timeout > 0 @message = nil end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
9 10 11 |
# File 'lib/em/tycoon/protocol/parser.rb', line 9 def buffer @buffer end |
#bytes_parsed ⇒ Object (readonly)
Returns the value of attribute bytes_parsed.
8 9 10 |
# File 'lib/em/tycoon/protocol/parser.rb', line 8 def bytes_parsed @bytes_parsed end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/em/tycoon/protocol/parser.rb', line 8 def @message end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/em/tycoon/protocol/parser.rb', line 8 def result @result end |
Instance Method Details
#parse_chunk(data) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/em/tycoon/protocol/parser.rb', line 18 def parse_chunk(data) @message ||= Message.(data) @bytes_parsed += @message.parse(data) @result = @message.data succeed(@message.data) if @message.parsed? return @bytes_parsed end |