Sha256: 70962ffef0cb98edbf5a8b03c836daef8eaf4b0bc305b34f27a6a72968684e12

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

require 'English'

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

              input = super(*others)

              if 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/readline.rb
polyfill-0.5.0 lib/polyfill/v2_4/io/instance/readline.rb
polyfill-0.4.0 lib/polyfill/v2_4/io/instance/readline.rb