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(headers = nil, &block) ⇒ BlockIO

Returns a new instance of BlockIO.



7
8
9
10
11
# File 'gems/aws-sdk-core/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?

Parameters:

  • bytes (Integer) (defaults to: nil)

    (nil)

  • output_buffer (String) (defaults to: nil)

    (nil)

Returns:

  • (String, nil)


24
25
26
27
# File 'gems/aws-sdk-core/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

#sizeInteger

Returns:

  • (Integer)


30
31
32
# File 'gems/aws-sdk-core/lib/seahorse/client/block_io.rb', line 30

def size
  @size
end

#write(chunk) ⇒ Integer

Parameters:

  • chunk (String)

Returns:

  • (Integer)


15
16
17
18
19
# File 'gems/aws-sdk-core/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