Class StringIO
In: yaml/stringio.rb
Parent: Object

StringIO based on code by MoonWolf

Methods

eof   eof?   new   pos   readline   rewind   seek  

Public Class methods

[Source]

# File yaml/stringio.rb, line 9
        def initialize(string="")
            @string=string
            @pos=0
            @eof=(string.size==0)
        end

Public Instance methods

[Source]

# File yaml/stringio.rb, line 17
        def eof
            @eof
        end
eof?()

Alias for eof

[Source]

# File yaml/stringio.rb, line 14
        def pos
            @pos
        end

[Source]

# File yaml/stringio.rb, line 21
        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

[Source]

# File yaml/stringio.rb, line 35
        def rewind
            seek(0,0)
        end

[Source]

# File yaml/stringio.rb, line 38
        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

[Validate]