Sha256: a0ab844291152e22ffe1176fd2803f74f30c701e90e1b46168907f3e1c876a0d

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

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 { |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.singleton_class 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/class/readlines.rb