Sha256: cbfa0747bd36732e4a2375fa5856b16c6bce860153d52ac23588a5c276aae712

Contents?: true

Size: 550 Bytes

Versions: 3

Compression:

Stored size: 550 Bytes

Contents

require "hamster/list"

# Monkey-patches to Ruby's built-in `IO` class.
# @see http://www.ruby-doc.org/core/IO.html
class IO
  # 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]
  def to_list(sep = $/) # global input record separator
    Hamster::LazyList.new do
      line = gets(sep)
      if line
        Hamster::Cons.new(line, to_list)
      else
        EmptyList
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/lib/hamster/core_ext/io.rb
hamster-3.0.0 lib/hamster/core_ext/io.rb
hamster-2.0.0 lib/hamster/core_ext/io.rb