Sha256: 46ee9b597532b53736622c1564e38ccdcf6eaaa2ff0176edb1f9bd6a93d7cbaa

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

require 'English'

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

              input = super(*others)

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

                input.chomp!(separator)
              end

              input
            end
          end

          refine ::IO 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/instance/gets.rb
polyfill-0.5.0 lib/polyfill/v2_4/io/instance/gets.rb
polyfill-0.4.0 lib/polyfill/v2_4/io/instance/gets.rb