Class: OptionParser
- Inherits:
-
Object
- Object
- OptionParser
- Defined in:
- lib/cmdparse.rb
Overview
Extension for OptionParser objects to allow access to some internals.
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
Access the option list stack.
Instance Method Summary collapse
-
#banner? ⇒ Boolean
Returns
true
if a banner has been set. -
#options_defined? ⇒ Boolean
Returns
true
if at least one local option is defined.
Instance Attribute Details
#stack ⇒ Object (readonly)
Access the option list stack.
20 21 22 |
# File 'lib/cmdparse.rb', line 20 def stack @stack end |
Instance Method Details
#banner? ⇒ Boolean
Returns true
if a banner has been set.
37 38 39 |
# File 'lib/cmdparse.rb', line 37 def !@banner.nil? end |
#options_defined? ⇒ Boolean
Returns true
if at least one local option is defined.
The zeroth stack element is not respected when doing the query because it contains either the OptionParser::DefaultList or a CmdParse::MultiList with the global options of the CmdParse::CommandParser.
27 28 29 30 31 32 33 34 |
# File 'lib/cmdparse.rb', line 27 def stack[1..-1].each do |list| list.each_option do |switch| return true if switch.kind_of?(OptionParser::Switch) && (switch.short || switch.long) end end false end |