class OfflineSort::Chunk::InputOutput::Base

Constants

MethodNotImplementedError

Attributes

io[R]

Public Class Methods

new(io) click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 12
def initialize(io)
  @io = io
end

Public Instance Methods

close() click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 37
def close
  io.close
end
each() click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 41
def each
  Enumerator.new do |yielder|
    loop do
      yielder.yield(read_entry)
    rescue EOFError
      break
    end
  end
end
flush() click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 28
def flush
  io.flush
end
read_entry() click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 16
def read_entry
  raise MethodNotImplementedError.new("#{__method__} must be overridden by #{self.class}")
end
rewind() click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 32
def rewind
  flush
  io.rewind
end
write_entries(entries) click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 24
def write_entries(entries)
  entries.each { |entry| write_entry(entry) }
end
write_entry(_entry) click to toggle source
# File lib/offline_sort/chunk/input_output/base.rb, line 20
def write_entry(_entry)
  raise MethodNotImplementedError.new("#{__method__} must be overridden by #{self.class}")
end