Class: Faraday::CompositeReadIO

### Home Classes Methods

### In Files

- lib/faraday/upload_io.rb

### Parent

Object

### Methods

- ::new
- #close
- #ensure_open_and_readable
- #length
- #read
- #rewind

### Class/Module Index

Quicksearch

- Faraday
- Faraday::Adapter
- Faraday::Adapter::EMHttp
- Faraday::Adapter::EMHttp::Manager
- Faraday::Adapter::EMHttp::Options
- Faraday::Adapter::EMSynchrony
- Faraday::Adapter::EMSynchrony::ParallelManager
- Faraday::Adapter::Excon
- Faraday::Adapter::NetHttp
- Faraday::Adapter::NetHttpPersistent
- Faraday::Adapter::Parallelism
- Faraday::Adapter::Patron
- Faraday::Adapter::Rack
- Faraday::Adapter::Test
- Faraday::Adapter::Test::Stub
- Faraday::Adapter::Test::Stubs
- Faraday::Adapter::Test::Stubs::NotFound
- Faraday::Adapter::Typhoeus
- Faraday::AutoloadHelper
- Faraday::Builder
- Faraday::Builder::Handler
- Faraday::Builder::StackLocked
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::Error
- Faraday::Error::ClientError
- Faraday::Error::ConnectionFailed
- Faraday::Error::MissingDependency
- Faraday::Error::ParsingError
- Faraday::Error::ResourceNotFound
- Faraday::Error::TimeoutError
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- Object

No matching classes.

# Faraday::CompositeReadIO

Similar but not compatible with ::CompositeReadIO provided by multipart-post.

### Public Class Methods

new(*parts) click to toggle source

    # File lib/faraday/upload_io.rb, line 13
    def initialize(*parts)
      @parts = parts.flatten
      @ios = @parts.map { |part| part.to_io }
      @index = 0
    end

### Public Instance Methods

close() click to toggle source

    # File lib/faraday/upload_io.rb, line 46
    def close
      @ios.each { |io| io.close }
    end

ensure_open_and_readable() click to toggle source

    # File lib/faraday/upload_io.rb, line 50
    def ensure_open_and_readable
      # Rubinius compatibility
    end

length() click to toggle source

    # File lib/faraday/upload_io.rb, line 19
    def length
      @parts.inject(0) { |sum, part| sum + part.length }
    end

read(length = nil, outbuf = nil) click to toggle source

Read from IOs in order until `length` bytes have been received.

    # File lib/faraday/upload_io.rb, line 29
    def read(length = nil, outbuf = nil)
      got_result = false
      outbuf = outbuf ? outbuf.replace("") : ""

      while io = current_io
        if result = io.read(length)
          got_result ||= !result.nil?
          result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
          outbuf << result
          length -= result.length if length
          break if length == 0
        end
        advance_io
      end
      (!got_result && length) ? nil : outbuf
    end

rewind() click to toggle source

    # File lib/faraday/upload_io.rb, line 23
    def rewind
      @ios.each { |io| io.rewind }
      @index = 0
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.