Method: Polyfill::V2_4::IO::ClassMethods#readlines

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

#readlines(file_name, *args) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/polyfill/v2_4/io.rb', line 41

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