Module: Polyfill::V2_4::IO::Instance::Gets::Method

Defined in:
lib/polyfill/v2_4/io/instance/gets.rb

Instance Method Summary collapse

Instance Method Details

#gets(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/polyfill/v2_4/io/instance/gets.rb', line 9

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