class Nmax::Integer

Constants

MAX_LENGTH

Public Instance Methods

perform(io) click to toggle source
Calls superclass method Nmax::Base#perform
# File lib/nmax/integer.rb, line 7
def perform(io)
  super do
    io.each_line&.reduce([]) do |acc, line|
      acc += line.scan(Regexp.new("\\d{1,#{MAX_LENGTH}}"))
                 .map(&:to_i)
                 .sort
                 .last(count)
      acc.sort.last(count)
    end
  end
end