Class: GLI::Switch
- Inherits:
-
CommandLineOption
- Object
- CommandLineToken
- CommandLineOption
- GLI::Switch
- Defined in:
- lib/gli/switch.rb
Overview
Defines a command line switch
Instance Attribute Summary collapse
-
#default_value ⇒ Object
:nodoc:.
-
#negatable ⇒ Object
readonly
Returns the value of attribute negatable.
Attributes inherited from CommandLineOption
Attributes inherited from CommandLineToken
#aliases, #description, #long_description, #name
Instance Method Summary collapse
- #arguments_for_option_parser ⇒ Object
-
#initialize(names, options = {}) ⇒ Switch
constructor
Creates a new switch.
- #negatable? ⇒ Boolean
Methods inherited from CommandLineOption
Methods inherited from CommandLineToken
Constructor Details
#initialize(names, options = {}) ⇒ Switch
Creates a new switch
names - Array of symbols or strings representing the names of this switch options - hash of options:
:desc - the short description
:long_desc - the long description
:negatable - true or false if this switch is negatable; defaults to true
:default_value - ignored, switches default to false
18 19 20 21 22 |
# File 'lib/gli/switch.rb', line 18 def initialize(names, = {}) super(names,) @default_value = false @negatable = [:negatable].nil? ? true : [:negatable] end |
Instance Attribute Details
#default_value ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/gli/switch.rb', line 7 def default_value @default_value end |
#negatable ⇒ Object (readonly)
Returns the value of attribute negatable.
8 9 10 |
# File 'lib/gli/switch.rb', line 8 def negatable @negatable end |
Instance Method Details
#arguments_for_option_parser ⇒ Object
24 25 26 |
# File 'lib/gli/switch.rb', line 24 def arguments_for_option_parser all_forms_a end |
#negatable? ⇒ Boolean
28 29 30 |
# File 'lib/gli/switch.rb', line 28 def negatable? @negatable end |