Sha256: 4b5b36a85639660f39efa75db74cc627829f80dc189002e0f655248e75ea8414

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

module Seahorse
  module Client
    class BlockIO

      def initialize(&block)
        @block = block
        @size = 0
      end

      # @param [String] chunk
      # @return [Integer]
      def write(chunk)
        @block.call(chunk)
        chunk.bytesize.tap { |chunk_size| @size += chunk_size }
      end

      # @param [Integer] bytes (nil)
      # @param [String] output_buffer (nil)
      # @return [String, nil]
      def read(bytes = nil, output_buffer = nil)
        data = bytes ? nil : ''
        output_buffer ? output_buffer.replace(data || '') : data
      end

      # @return [Integer]
      def size
        @size
      end

      # It is not possible to rewind a {BlockIO} object as the data has
      # already been yielded.
      # @return [NotImplementedError]
      def rewind
        raise NotImplementedError
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0.rc1 vendor/seahorse/lib/seahorse/client/block_io.rb