You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Seahorse::Client::BlockIO

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-core/lib/seahorse/client/block_io.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ BlockIO

Returns a new instance of BlockIO



5
6
7
8
# File 'gems/aws-sdk-core/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?

Parameters:

  • bytes (Integer) (defaults to: nil)

    (nil)

  • output_buffer (String) (defaults to: nil)

    (nil)

Returns:

  • (String, nil)


20
21
22
23
# File 'gems/aws-sdk-core/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

#sizeInteger

Returns:

  • (Integer)


26
27
28
# File 'gems/aws-sdk-core/lib/seahorse/client/block_io.rb', line 26

def size
  @size
end

#write(chunk) ⇒ Integer

Parameters:

  • chunk (String)

Returns:

  • (Integer)


12
13
14
15
# File 'gems/aws-sdk-core/lib/seahorse/client/block_io.rb', line 12

def write(chunk)
  @block.call(chunk)
  chunk.bytesize.tap { |chunk_size| @size += chunk_size }
end