Class: PrintPrimesTable::Options::DefaultOption

Inherits:
Object
  • Object
show all
Defined in:
lib/print_primes_table/options/default_option.rb

Class Method Summary collapse

Class Method Details

.process(args) ⇒ Object

procces the default option to print the table. The validator print an error if there is an exception

Parameters:

  • args (Array)

    the first argument is a integer quantity of prime collection



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/print_primes_table/options/default_option.rb', line 10

def process(args)
  validator = Validators::DefaultValidator.validate(args)
  if validator == :valid
    if args.count>0
      total = Integer(args[0])
      primes = Primes.new total
    else
      primes= Primes.new
    end
    primes.print_table

  else
    puts validator
  end
end