eof()
click to toggle source
eof?()
click to toggle source
pos()
click to toggle source
readline(rs=$/)
click to toggle source
def readline(rs=$/)
if @eof
raise EOFError
else
if p = @string[@pos..-1]=~rs
line = @string[@pos,p+1]
else
line = @string[@pos..-1]
end
@pos+=line.size
@eof =true if @pos==@string.size
$_ = line
end
end
rewind()
click to toggle source
seek(offset,whence)
click to toggle source
def seek(offset,whence)
case whence
when 0
@pos=offset
when 1
@pos+=offset
when 2
@pos=@string.size+offset
end
@eof=(@pos>=@string.size)
0
end