lib/composite_io.rb
def read(amount = nil, buf = nil)
    buffer = buf || ''
    done = if amount; nil; else ''; end
    partial_amount = amount

    loop do
      result = done

      while !@ios.empty? && (result = @ios.first.read(partial_amount)) == done
        @ios.shift
      end

      result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
      buffer << result if result
      partial_amount -= result.length if partial_amount && result != done

      break if partial_amount && partial_amount <= 0
      break if result == done
    end

    if buffer.length > 0
      buffer
    else
      done
    end
  end
# Read from the IO object, overlapping across underlying streams as necessary.
Read from the IO object, overlapping across underlying streams as necessary.
Read from the IO object overlapping across underlying streams as necessary .
def read(amount = nil, buf = nil)
    buffer = buf || ''
    done = if amount; nil; else ''; end
    partial_amount = amount
    loop do
      result = done
      while !@ios.empty? && (result = @ios.first.read(partial_amount)) == done
        @ios.shift
      end
      result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
      buffer << result if result
      partial_amount -= result.length if partial_amount && result != done
      break if partial_amount && partial_amount <= 0
      break if result == done
    end
    if buffer.length > 0
      buffer
    else
      done
    end
  end
def read ( amount = nil , buf = nil ) buffer = buf || '' done = if amount ; nil ; else '' ; end partial_amount = amount loop do result = done while ! @ios . empty? && ( result = @ios . first . read ( partial_amount ) ) == done @ios . shift end result . force_encoding ( "BINARY" ) if result . respond_to? ( :force_encoding ) buffer << result if result partial_amount -= result . length if partial_amount && result != done break if partial_amount && partial_amount <= 0 break if result == done end if buffer . length > 0 buffer else done end end
Read from the IO object, overlapping across underlying streams as necessary.
Read from the IO object overlapping across underlying streams as necessary .
amount
buf