Class: HTTP::Request::Body::ProcIO
- Inherits:
-
Object
- Object
- HTTP::Request::Body::ProcIO
- Defined in:
- lib/http/request/body.rb
Overview
This class provides a “writable IO” wrapper around a proc object, with #write simply calling the proc, which we can pass in as the “destination IO” in IO.copy_stream.
Instance Method Summary collapse
-
#initialize(block) ⇒ ProcIO
constructor
Initialize a new ProcIO wrapper.
-
#write(data) ⇒ Integer
Write data by calling the wrapped proc.
Constructor Details
#initialize(block) ⇒ ProcIO
Initialize a new ProcIO wrapper
163 164 165 |
# File 'lib/http/request/body.rb', line 163 def initialize(block) @block = block end |
Instance Method Details
#write(data) ⇒ Integer
Write data by calling the wrapped proc
174 175 176 177 |
# File 'lib/http/request/body.rb', line 174 def write(data) @block.call(data) data.bytesize end |