Sha256: ed1ec8683a2ae93728873a2847a40738b948b7af9326eb8c8244292fd7ab5e03
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'English' module Polyfill module V2_4 module IO module Instance module EachLine module Method def each_line(*args) hash, others = args.partition { |arg| arg.is_a?(::Hash) } chomps = hash[0] && hash[0][:chomp] unless block_given? return super(*others) unless chomps separator = others.find do |other| other.respond_to?(:to_str) end || $INPUT_RECORD_SEPARATOR return ::Enumerator.new do |yielder| super(*others) do |line| yielder.yield(line.chomp(separator)) end end end block = if chomps separator = others.find do |other| other.respond_to?(:to_str) end || $INPUT_RECORD_SEPARATOR proc do |line| yield(line.chomp(separator)) end else Proc.new end super(*others, &block) end end refine ::IO do include Method end def self.included(base) base.include Method end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
polyfill-0.5.0 | lib/polyfill/v2_4/io/instance/each_line.rb |
polyfill-0.4.0 | lib/polyfill/v2_4/io/instance/each_line.rb |