Sha256: 76a51ba8ab8e798073c246c0659c7d8ccecbbe328cd0dc53ded0f4b578a3d154

Contents?: true

Size: 824 Bytes

Versions: 3

Compression:

Stored size: 824 Bytes

Contents

require 'English'

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

              inputs = super(file_name, *others)

              if hash[0] && hash[0][:chomp]
                separator = others.find do |other|
                  other.respond_to?(:to_str)
                end || $INPUT_RECORD_SEPARATOR

                inputs.each { |input| input.chomp!(separator) }
              end

              inputs
            end
          end

          refine ::IO.singleton_class do
            include Method
          end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polyfill-0.6.0 lib/polyfill/v2_4/io/class/readlines.rb
polyfill-0.5.0 lib/polyfill/v2_4/io/class/readlines.rb
polyfill-0.4.0 lib/polyfill/v2_4/io/class/readlines.rb