Class: PrintPrimesTable::Options::OnlyPrimesOption

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

Overview

to print only a list of primes collection

Author:

Class Method Summary (collapse)

Class Method Details

+ (Object) process(args, options)

process the input to print the list if it pass the DefaultValidator.validate

Parameters:

  • args (Array)

    the first argument is the quantity of primes collection

  • options (Array)

    if in future we will want to add options



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

def process(args,options)
	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.list_numbers
	else
		puts validator
	end
end