class IO

Monkey-patches to Ruby's built-in `IO` class. @see www.ruby-doc.org/core/IO.html

Public Instance Methods

to_list(sep = $/) click to toggle source

Return a lazy list of “records” read from this IO stream. “Records” are delimited by `$/`, the global input record separator string. By default, it is `“n”`, a newline.

@return [List]

# File lib/immutable/core_ext/io.rb, line 11
def to_list(sep = $/) # global input record separator
  Immutable::LazyList.new do
    line = gets(sep)
    if line
      Immutable::Cons.new(line, to_list)
    else
      EmptyList
    end
  end
end