Module: PrimeProducts::CLI

Defined in:
lib/prime_products/cli.rb

Constant Summary collapse

DEFAULT_NUMBER_OF_PRIMES =
10

Class Method Summary collapse

Class Method Details

.call(output: $stdout, arguments: ARGV) ⇒ Object

Generates a multiplication table of the first N primes (specified by a command line argument by default) and outputs it to the specified output (‘STDOUT by default).

Parameters:

  • output (IO) (defaults to: $stdout)

    the output to print the table to

  • arguments (Array) (defaults to: ARGV)

    the CLI arguments (where the first argument is expected to contain the number of primes to use, starting from zero)



14
15
16
17
18
# File 'lib/prime_products/cli.rb', line 14

def self.call(output: $stdout, arguments: ARGV)
  number_of_primes = arguments[0]&.to_i || DEFAULT_NUMBER_OF_PRIMES

  output.puts PrimeProducts.generate_table(number_of_primes: number_of_primes)
end