Class: Foo

Inherits:
Object
  • Object
show all
Defined in:
lib/numru/misc/keywordopt.rb

Overview

:nodoc:

Constant Summary collapse

@@opt_hoge =
Misc::KeywordOpt.new(
  ['flag',   false, 'whether or not ...'],
  ['number', 1,     'number of ...'],
  ['fff',    1,     'fff...'],
  ['help',  false, 'show help message']
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.change_default(hash) ⇒ Object



376
377
378
# File 'lib/numru/misc/keywordopt.rb', line 376

def self.change_default(hash)
  @@opt_hoge.set(hash)
end

Instance Method Details

#hoge(regular_arg1, regular_arg2, options = nil) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
# File 'lib/numru/misc/keywordopt.rb', line 379

def hoge(regular_arg1, regular_arg2, options=nil)
  opt = @@opt_hoge.interpret(options)
  if opt['help']
    puts "* Description of options:\n" + @@opt_hoge.help
    puts ' Current values='+opt.inspect
    raise Misc::HelpMessagingException, '** show help message and raise **'
  end
  # do what you want below 
  # (options are set in the Hash opt: opt['flag'] and opt['number'])
  p opt
end