class RemoteRuby::StreamCacher

Decorates the source stream and writes to the cache stream as the source is being read

Attributes

cache_stream[R]
source_stream[R]

Public Class Methods

new(source_stream, cache_stream) click to toggle source
# File lib/remote_ruby/stream_cacher.rb, line 5
def initialize(source_stream, cache_stream)
  @source_stream = source_stream
  @cache_stream = cache_stream
end

Public Instance Methods

close() click to toggle source
# File lib/remote_ruby/stream_cacher.rb, line 26
def close
  source_stream.close
end
eof?() click to toggle source
# File lib/remote_ruby/stream_cacher.rb, line 22
def eof?
  source_stream.eof?
end
read(*args) click to toggle source
# File lib/remote_ruby/stream_cacher.rb, line 10
def read(*args)
  res = source_stream.read(*args)
  cache_stream.write(res)
  res
end
readline() click to toggle source
# File lib/remote_ruby/stream_cacher.rb, line 16
def readline
  res = source_stream.readline
  cache_stream.write(res)
  res
end