class Seahorse::Client::BlockIO

Public Class Methods

new(&block) click to toggle source
# File lib/seahorse/client/block_io.rb, line 5
def initialize(&block)
  @block = block
  @size = 0
end

Public Instance Methods

read(bytes = nil, output_buffer = nil) click to toggle source

@param [Integer] bytes (nil) @param [String] output_buffer (nil) @return [String, nil]

# 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() click to toggle source

@return [Integer]

# File lib/seahorse/client/block_io.rb, line 26
def size
  @size
end
write(chunk) click to toggle source

@param [String] chunk @return [Integer]

# File lib/seahorse/client/block_io.rb, line 12
def write(chunk)
  @block.call(chunk)
  chunk.bytesize.tap { |chunk_size| @size += chunk_size }
end