Class: CommandoOpt
- Inherits:
-
Object
- Object
- CommandoOpt
- Defined in:
- lib/scriptroute/commando.rb
Overview
base class of command options. all options must have tags and a helpful description… or at least a description.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#help ⇒ String
The help text for this option, comprising tags, default, and description.
- #seek(argv) ⇒ Object
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/scriptroute/commando.rb', line 4 def description @description end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/scriptroute/commando.rb', line 4 def @tags end |
Instance Method Details
#help ⇒ String
Returns the help text for this option, comprising tags, default, and description.
17 18 19 20 21 |
# File 'lib/scriptroute/commando.rb', line 17 def help " %20s %4s %-72s" % [ .join(", "), self.string_default, @description ] end |
#seek(argv) ⇒ Object
Note:
Modifies argument (removing parsed options)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/scriptroute/commando.rb', line 24 def seek(argv) argv.each_with_index { |a,i| .each { |t| if(a == t) then argv.delete_at(i) if(takes_argument?) then set(argv[i]) argv.delete_at(i) else set(TRUE) # if closure, then the arg is ignored. end end } } end |