Sha256: 979693698a4e05335d57078fa1e0c94f3a2d6813f293592a040bdc2589395fcc

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module Polyfill
  module V2_4
    module IO
      module Instance
        module Readlines
          module Method
            def readlines(*args)
              hash, others = args.partition { |arg| arg.is_a?(::Hash) }

              inputs = super(*others)

              if hash[0] && hash[0][:chomp]
                separator = others.find { |other| other.respond_to?(:to_str) }
                if separator
                  inputs.each { |input| input.chomp!(separator) }
                else
                  inputs.each(&:chomp!)
                end
              end

              inputs
            end
          end

          if RUBY_VERSION < '2.4.0'
            refine ::IO do
              include Method
            end

            def self.included(base)
              base.include Method
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.3.0 lib/polyfill/v2_4/io/instance/readlines.rb