Class: NumRu::Misc::KeywordOptAutoHelp
- Inherits:
-
KeywordOpt
- Object
- KeywordOpt
- NumRu::Misc::KeywordOptAutoHelp
- Defined in:
- lib/numru/misc/keywordopt.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ KeywordOptAutoHelp
constructor
A new instance of KeywordOptAutoHelp.
- #interpret(hash) ⇒ Object
- #set(hash) ⇒ Object
Methods inherited from KeywordOpt
#[], #help, #keys, #select_existent
Constructor Details
#initialize(*args) ⇒ KeywordOptAutoHelp
Returns a new instance of KeywordOptAutoHelp.
372 373 374 375 |
# File 'lib/numru/misc/keywordopt.rb', line 372 def initialize(*args) args.push(['help', false, 'show help message if true']) super(*args) end |
Instance Method Details
#interpret(hash) ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/numru/misc/keywordopt.rb', line 377 def interpret(hash) begin out = super(hash) rescue raise $!.inspect + "\n Available parameters are:\n" + help end if out['help'] puts "<< Description of options >>\n" + help puts ' Current values=' + out.inspect raise Misc::HelpMessagingException, '** help messaging done **' end out end |
#set(hash) ⇒ Object
391 392 393 394 395 396 397 398 |
# File 'lib/numru/misc/keywordopt.rb', line 391 def set(hash) raise ArgumentError, "not a hash" if !hash.is_a?(Hash) if hash['help'] puts "<< Description of options >>\n" + help raise Misc::HelpMessagingException, '** help messaging done **' end super end |