Class: Seahorse::Client::BlockIO
- Inherits:
-
Object
- Object
- Seahorse::Client::BlockIO
- Defined in:
- lib/seahorse/client/block_io.rb
Instance Method Summary collapse
-
#initialize(headers = nil, &block) ⇒ BlockIO
constructor
A new instance of BlockIO.
- #read(bytes = nil, output_buffer = nil) ⇒ String?
- #size ⇒ Integer
- #write(chunk) ⇒ Integer
Constructor Details
#initialize(headers = nil, &block) ⇒ BlockIO
Returns a new instance of BlockIO.
7 8 9 10 11 |
# File 'lib/seahorse/client/block_io.rb', line 7 def initialize(headers = nil, &block) @headers = headers @block = block @size = 0 end |
Instance Method Details
#read(bytes = nil, output_buffer = nil) ⇒ String?
24 25 26 27 |
# File 'lib/seahorse/client/block_io.rb', line 24 def read(bytes = nil, output_buffer = nil) data = bytes ? nil : '' output_buffer ? output_buffer.replace(data || '') : data end |
#size ⇒ Integer
30 31 32 |
# File 'lib/seahorse/client/block_io.rb', line 30 def size @size end |
#write(chunk) ⇒ Integer
15 16 17 18 19 |
# File 'lib/seahorse/client/block_io.rb', line 15 def write(chunk) @block.call(chunk, @headers) ensure chunk.bytesize.tap { |chunk_size| @size += chunk_size } end |