module SafeGetsModule

Public Instance Methods

safe_gets(max_length = 1024) click to toggle source
# File vendor/qwik/lib/qwik/util-safe.rb, line 17
def safe_gets (max_length = 1024)
  s = ''
  while ! self.eof?
    c = self.read(1)          # FIXME: This code may be slow.
    s << c

    if max_length < s.length
      raise TooLongLine
    end

    if c == "\n"
      return s
    end
  end

  res = if s.empty? then nil else s end
  return res
end