Class: Web::Connection::CallbackBuffer
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
Instance Method Summary collapse
- #clean ⇒ Object
- #flush ⇒ Object
- #get_contents ⇒ Object
-
#initialize(&callback) ⇒ CallbackBuffer
constructor
A new instance of CallbackBuffer.
Constructor Details
#initialize(&callback) ⇒ CallbackBuffer
Returns a new instance of CallbackBuffer.
433 434 435 436 |
# File 'lib/web/connection.rb', line 433 def initialize( &callback ) @callback = callback @buffer = StringIO.new end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
432 433 434 |
# File 'lib/web/connection.rb', line 432 def callback @callback end |
Instance Method Details
#clean ⇒ Object
452 453 454 |
# File 'lib/web/connection.rb', line 452 def clean @buffer = StringIO.new end |
#flush ⇒ Object
438 439 440 441 442 443 444 445 446 |
# File 'lib/web/connection.rb', line 438 def flush result = if @callback @callback.call(@buffer.string) else @buffer.string end self.clean result end |
#get_contents ⇒ Object
448 449 450 |
# File 'lib/web/connection.rb', line 448 def get_contents @buffer.string end |