class Spektrum::Log::BufferedFile
Public Class Methods
new(uri, mode)
click to toggle source
# File lib/spektrum/log/buffered_file.rb, line 8 def initialize(uri, mode) @io = open(uri, mode) @buffer = StringIO.new end
Public Instance Methods
close()
click to toggle source
# File lib/spektrum/log/buffered_file.rb, line 18 def close @buffer = nil @io.close end
read(length)
click to toggle source
# File lib/spektrum/log/buffered_file.rb, line 13 def read(length) fetch_chunk if (@buffer.length - @buffer.pos) < length @buffer.read(length) end
Private Instance Methods
fetch_chunk()
click to toggle source
# File lib/spektrum/log/buffered_file.rb, line 25 def fetch_chunk @buffer = StringIO.new.tap do |b| b << @buffer.read b << @io.read(4096) b.seek(0) end end