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
 9:         def initialize(string="")
10:             @string=string
11:             @pos=0
12:             @eof=(string.size==0)
13:         end

Public Instance methods

[Source]

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

Alias for eof

[Source]

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

[Source]

    # File yaml/stringio.rb, line 21
21:         def readline(rs=$/)
22:             if @eof
23:                 raise EOFError
24:             else
25:                 if p = @string[@pos..-1]=~rs
26:                     line = @string[@pos,p+1]
27:                 else
28:                     line = @string[@pos..-1]
29:                 end
30:                 @pos+=line.size
31:                 @eof =true if @pos==@string.size
32:                 $_ = line
33:             end
34:         end

[Source]

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

[Source]

    # File yaml/stringio.rb, line 38
38:         def seek(offset,whence)
39:             case whence
40:             when 0
41:                 @pos=offset
42:             when 1
43:                 @pos+=offset
44:             when 2
45:                 @pos=@string.size+offset
46:             end
47:             @eof=(@pos>=@string.size)
48:             0
49:         end

Search

Google

Ruby API Docs

Links