Class: Optimist::BooleanOption
- Defined in:
- lib/rbcli/components/parser/optimist/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, get_klass_from_default, get_type_from_disdef, handle_long_opt, handle_short_opt, #multi, #multi_arg?, #opts, #opts=, register_alias, #required?, #short?, #single_arg?, #type_format
Constructor Details
#initialize ⇒ BooleanOption
Returns a new instance of BooleanOption.
834 835 836 837 |
# File 'lib/rbcli/components/parser/optimist/optimist.rb', line 834 def initialize super() @default = false end |
Instance Method Details
#flag? ⇒ Boolean
839 840 841 |
# File 'lib/rbcli/components/parser/optimist/optimist.rb', line 839 def flag? true; end |
#parse(_paramlist, neg_given) ⇒ Object
843 844 845 846 |
# File 'lib/rbcli/components/parser/optimist/optimist.rb', line 843 def parse(_paramlist, neg_given) return _paramlist[0] if @multi_given return(self.name.to_s =~ /^no_/ ? neg_given : !neg_given) end |