Class: Trollop::BooleanOption
- Defined in:
- lib/rbcli/util/trollop.rb
Overview
Flag option. Has no arguments. Can be negated with “no-”.
Instance Attribute Summary
Attributes inherited from Option
#default, #long, #multi_given, #name, #permitted, #short
Instance Method Summary collapse
- #flag? ⇒ Boolean
-
#initialize ⇒ BooleanOption
constructor
A new instance of BooleanOption.
- #parse(_paramlist, neg_given) ⇒ Object
Methods inherited from Option
#array_default?, #callback, create, #desc, #description_with_default, #description_with_permitted, #educate, #full_description, #multi, #multi_arg?, #opts, #opts=, register_alias, #required?, #short?, #single_arg?, #type_format
Constructor Details
#initialize ⇒ BooleanOption
Returns a new instance of BooleanOption.
790 791 792 793 |
# File 'lib/rbcli/util/trollop.rb', line 790 def initialize super() @default = false end |
Instance Method Details
#flag? ⇒ Boolean
794 |
# File 'lib/rbcli/util/trollop.rb', line 794 def flag? ; true ; end |
#parse(_paramlist, neg_given) ⇒ Object
795 796 797 |
# File 'lib/rbcli/util/trollop.rb', line 795 def parse(_paramlist, neg_given) return(self.name.to_s =~ /^no_/ ? neg_given : !neg_given) end |