Class: LoremJP::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/lorem_jp/cli.rb

Overview

Class for command line interface of Japanese Lorem Ipsum

Class Method Summary collapse

Class Method Details

.mainvoid

This method returns an undefined value.

Main routine for command line interface of lorem_jp



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lorem_jp/cli.rb', line 12

def self.main
  dict  = nil
  chain = nil

  opt = OptionParser.new

  opt.on('-f DICT',  'dictionary filename') {
    |v| dict = v
  }
  opt.on('-c CHAIN', 'chain of precedences' +
                     ' (default: set in dictionary)') {
    |v| chain = v.to_i
  }

  opt.parse! ARGV

  options = {}
  options[:dictionary] = dict   if dict
  options[:chain]      = chain  if chain

  puts LoremJP.sentence(options)
end