Class: Seahorse::Client::BlockIO
- Inherits:
-
Object
- Object
- Seahorse::Client::BlockIO
- Defined in:
- lib/seahorse/client/block_io.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ BlockIO
constructor
A new instance of BlockIO.
- #read(bytes = nil, output_buffer = nil) ⇒ String?
- #size ⇒ Integer
- #write(chunk) ⇒ Integer
Constructor Details
#initialize(&block) ⇒ BlockIO
Returns a new instance of BlockIO.
5 6 7 8 |
# File 'lib/seahorse/client/block_io.rb', line 5 def initialize(&block) @block = block @size = 0 end |
Instance Method Details
#read(bytes = nil, output_buffer = nil) ⇒ String?
20 21 22 23 |
# File 'lib/seahorse/client/block_io.rb', line 20 def read(bytes = nil, output_buffer = nil) data = bytes ? nil : '' output_buffer ? output_buffer.replace(data || '') : data end |
#size ⇒ Integer
26 27 28 |
# File 'lib/seahorse/client/block_io.rb', line 26 def size @size end |
#write(chunk) ⇒ Integer
12 13 14 15 |
# File 'lib/seahorse/client/block_io.rb', line 12 def write(chunk) @block.call(chunk) chunk.bytesize.tap { |chunk_size| @size += chunk_size } end |