Class: Rucc::FileIO
- Inherits:
-
Object
- Object
- Rucc::FileIO
- Defined in:
- lib/rucc/file_io.rb
Constant Summary collapse
- EOF =
nil
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1) error(“fstat failed: %s”, strerror(errno)); r->mtime = st.st_mtime;.
-
#line ⇒ Object
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1) error(“fstat failed: %s”, strerror(errno)); r->mtime = st.st_mtime;.
-
#name ⇒ Object
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1) error(“fstat failed: %s”, strerror(errno)); r->mtime = st.st_mtime;.
-
#ntok ⇒ Object
readonly
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1) error(“fstat failed: %s”, strerror(errno)); r->mtime = st.st_mtime;.
Instance Method Summary collapse
- #close ⇒ Object
- #incr_ntok! ⇒ Object
-
#initialize(io, name) ⇒ FileIO
constructor
A new instance of FileIO.
- #mtime ⇒ Object
-
#readc ⇒ Char, NilClass
Nil at EOF.
- #unreadc(c) ⇒ Object
Constructor Details
#initialize(io, name) ⇒ FileIO
Returns a new instance of FileIO.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rucc/file_io.rb', line 7 def initialize(io, name) @io = io @name = name @line = 1 @column = 1 @ntok = 0 # Token counter @buflen = 0 @buf = Array.new(3) @last = Object.new # NOTE: Not use nil because nil means EOF. Set dummy data at first. # TODO(south37) Set @mtime # struct stat st; # if (fstat(fileno(file), &st) == -1) # error("fstat failed: %s", strerror(errno)); # r->mtime = st.st_mtime; end |
Instance Attribute Details
#column ⇒ Object (readonly)
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1)
error("fstat failed: %s", strerror(errno));
r->mtime = st.st_mtime;
23 24 25 |
# File 'lib/rucc/file_io.rb', line 23 def column @column end |
#line ⇒ Object
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1)
error("fstat failed: %s", strerror(errno));
r->mtime = st.st_mtime;
23 24 25 |
# File 'lib/rucc/file_io.rb', line 23 def line @line end |
#name ⇒ Object
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1)
error("fstat failed: %s", strerror(errno));
r->mtime = st.st_mtime;
23 24 25 |
# File 'lib/rucc/file_io.rb', line 23 def name @name end |
#ntok ⇒ Object (readonly)
TODO(south37) Set @mtime struct stat st; if (fstat(fileno(file), &st) == -1)
error("fstat failed: %s", strerror(errno));
r->mtime = st.st_mtime;
23 24 25 |
# File 'lib/rucc/file_io.rb', line 23 def ntok @ntok end |
Instance Method Details
#close ⇒ Object
63 64 65 |
# File 'lib/rucc/file_io.rb', line 63 def close @io.close end |
#incr_ntok! ⇒ Object
59 60 61 |
# File 'lib/rucc/file_io.rb', line 59 def incr_ntok! @ntok += 1 end |
#mtime ⇒ Object
67 68 69 70 |
# File 'lib/rucc/file_io.rb', line 67 def mtime Util.assert!{ @io.is_a?(File) } File.mtime(@io) end |
#readc ⇒ Char, NilClass
Returns nil at EOF.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rucc/file_io.rb', line 27 def readc while true do c = get if c == EOF return c end if (c != "\\") return c end c2 = get if c2 == "\n" next end unreadc(c2) return c end end |