Method: StringInput#gets

Defined in:
lib/extensions/crypt/crypt/stringio.rb

#getsObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/extensions/crypt/crypt/stringio.rb', line 126

def gets
  stream_check!
  if idx = @src.index(?\n, @pos)
    idx += 1  # "\n".size
    line = @src[ @pos ... idx ]
    @pos = idx
    @pos += 1 if @pos == @src.size
  else
    line = @src[ @pos .. -1 ]
    @pos = @src.size + 1
  end
  @lineno += 1

  line
end