Class: PrintPrimesTable::Client

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

Overview

Author:

Class Method Summary (collapse)

Class Method Details

+ (Object) get_command

capture command arguments and options



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/print_primes_table/client.rb', line 8

def get_command
	begin

		options = OPTIONS & ARGV
		args = ARGV - options
		process_command(args, options)

	rescue => err
		puts err.message
	end
end

+ (Object) process_command(args, options)

when the command has options, the option is executed when there isn't options execute the default option I think in future is possible to include more in the same instruction

Parameters:

  • args (Array)

    arguments captured in a console standard input

  • options (Array)

    the program is prepared to get one option but in



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/print_primes_table/client.rb', line 25

def process_command(args,options)

	options.each do |option|
		case option
		when '--only-primes'
			Options::OnlyPrimesOption.process(args, options)
		when '--help'
			Options::HelpOption.process(args, options)
		end
	end
	Options::DefaultOption.process(args) if options.count < 1

end