class IO

Public Class Methods

copy_stream(input, output) click to toggle source

IO.copy_stream backport

# File lib/epitools/core_ext/io.rb, line 9
def self.copy_stream(input, output)
  while chunk = input.read(8192)
    output.write(chunk)
  end
end

Public Instance Methods

each_line_with_offset() { |line, offset| ... } click to toggle source

Iterate over each line of the stream, yielding the line and the byte offset of the start of the line in the file

# File lib/epitools/core_ext/io.rb, line 19
def each_line_with_offset
  return to_enum(:each_line_with_offset) unless block_given?

  offset = 0

  each_line do |line|
    yield line, offset
    offset += line.bytesize
  end
end