Class: Rucc::FileIOList
- Inherits:
-
Object
- Object
- Rucc::FileIOList
- Extended by:
- Forwardable
- Defined in:
- lib/rucc/file_io_list.rb
Instance Method Summary collapse
- #current ⇒ FileIO
-
#initialize(file) ⇒ FileIOList
constructor
A new instance of FileIOList.
- #readc ⇒ Char, NilClass
- #stream_depth ⇒ Object
- #stream_stash(files) ⇒ Object
- #stream_unstash ⇒ Object
- #unreadc(c) ⇒ Object
Constructor Details
#initialize(file) ⇒ FileIOList
Returns a new instance of FileIOList.
8 9 10 11 |
# File 'lib/rucc/file_io_list.rb', line 8 def initialize(file) @files = [file] @stashed = [] # buffer for stashed files end |
Instance Method Details
#readc ⇒ Char, NilClass
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rucc/file_io_list.rb', line 20 def readc while true c = current.readc if !c.nil? # not EOF return c end if @files.size == 1 return c end f = @files.pop f.close next end raise "Must not reach here!" end |
#stream_depth ⇒ Object
52 53 54 |
# File 'lib/rucc/file_io_list.rb', line 52 def stream_depth @files.size end |
#stream_stash(files) ⇒ Object
43 44 45 46 |
# File 'lib/rucc/file_io_list.rb', line 43 def stream_stash(files) @stashed.push(@files) @files = files end |
#stream_unstash ⇒ Object
48 49 50 |
# File 'lib/rucc/file_io_list.rb', line 48 def stream_unstash @files = @stashed.pop end |
#unreadc(c) ⇒ Object
38 39 40 |
# File 'lib/rucc/file_io_list.rb', line 38 def unreadc(c) current.unreadc(c) end |