Class: PrintPrimesTable::Client
- Inherits:
-
Object
- Object
- PrintPrimesTable::Client
- Defined in:
- lib/print_primes_table/client.rb
Overview
Class Method Summary (collapse)
-
+ (Object) get_command
capture command arguments and options.
-
+ (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.
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 & ARGV args = ARGV - process_command(args, ) rescue => err puts err. 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
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,) .each do |option| case option when '--only-primes' Options::OnlyPrimesOption.process(args, ) when '--help' Options::HelpOption.process(args, ) end end Options::DefaultOption.process(args) if .count < 1 end |