Class: Optimist::BooleanOption
- Defined in:
- lib/rbcli/util/optimist.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, #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.
802 803 804 805 |
# File 'lib/rbcli/util/optimist.rb', line 802 def initialize super() @default = false end |
Instance Method Details
#flag? ⇒ Boolean
806 |
# File 'lib/rbcli/util/optimist.rb', line 806 def flag? ; true ; end |
#parse(_paramlist, neg_given) ⇒ Object
807 808 809 810 |
# File 'lib/rbcli/util/optimist.rb', line 807 def parse(_paramlist, neg_given) return _paramlist[0] if @multi_given return(self.name.to_s =~ /^no_/ ? neg_given : !neg_given) end |