From 95b06b00df7f8ef7164cc33cbf1fba6fa24e0a14 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 1 Nov 2009 18:03:51 -0500 Subject: [PATCH] Cleanup FakeFS::File by descending from StringIO. --- lib/fakefs/file.rb | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index fb5cc4b..962db08 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -1,5 +1,5 @@ module FakeFS - class File + class File < StringIO PATH_SEPARATOR = '/' MODES = [ @@ -214,48 +214,19 @@ module FakeFS file_creation_mode? ? create_missing_file : check_file_existence! - @stream = StringIO.new(@file.content, mode) + super(@file.content, mode) end def close @open = false end - def read(chunk = nil) - @stream.read(chunk) - end - - def rewind - @stream.rewind - end - def exists? true end - def puts(*content) - @stream.puts(*content) - end - - def write(content) - @stream.write(content) - end - alias_method :print, :write - alias_method :<<, :write - def flush; self; end - def seek(amount, whence = SEEK_SET) - @stream.seek(amount, whence) - end - - def pos - @stream.pos - end - - def pos=(pos) - @stream.pos=(pos) - end alias_method :tell=, :pos= private