Class: RFactor::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/r_factor/cli.rb

Class Method Summary collapse

Class Method Details

.startObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/r_factor/cli.rb', line 3

def self.start
  ARGV.each do |arg|
    number = arg.to_i
    unless number.to_s == arg
      puts "factor: '#{arg.gsub('\\'){'\\\\'}.gsub("'"){"\\'"}}' is not a valid positive integer"
      next
    end

    factors = RFactor.factor(number)
    puts "#{number}: #{factors.join(' ')}"
  end
end