Class: PrintPrimesTable::Options::HelpOption

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

Overview

to handle the help messages output

Author:

  • Diego Hernán Piccinini Lagos

Constant Summary collapse

MESSAGE =
{:headings=> ['Option','Description'],
  :rows => [
    ["default\n\nwithout\noption" , "Print a table across the top and down the left\nside are the 10 primes, and the body of the table\nshould contain the product of multiplying these numbers.\nThis option accept one param the quantity.\nFor example, if you want to print 20 type this\nprint_table_primes 20\n"
],[' ',' '],
  ["--only-primes" , "Print a list of 10 primes.\nThis option accept one param the quantity.\nFor example, if you want to print 20 type this\nprint_table_primes --only-primes 20\n"
],[' ',' '],
["--only-primes",'Print this help.']
  ]
}

Class Method Summary collapse

Class Method Details

.process(args, options) ⇒ Object

process the –help option to show the options availables.



34
35
36
37
38
39
40
41
42
43
# File 'lib/print_primes_table/options/help_option.rb', line 34

def process(args,options)
  validator = Validators::HelpValidator.validate(args)
  if validator == :valid

    table = Terminal::Table.new :headings => MESSAGE[:headings], :rows => MESSAGE[:rows]
    puts table
  else
    puts validator
  end
end