Class: Optimist::BooleanOption
Overview
Flag option. Has no arguments. Can be negated with “no-”.
Instance Attribute Summary
Attributes inherited from Option
#default, #long, #multi_given, #name, #permitted, #permitted_response, #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, #doesnt_need_autogen_short, #educate, #format_stdio, #full_description, #multi, #multi_arg?, #opts, #opts=, #permitted_type_valid?, #permitted_valid_string, #permitted_value?, register_alias, #required?, #single_arg?, #type_format, #validate_permitted
Constructor Details
#initialize ⇒ BooleanOption
Returns a new instance of BooleanOption.
998 999 1000 1001 |
# File 'lib/optimist.rb', line 998 def initialize super() @default = false end |
Instance Method Details
#flag? ⇒ Boolean
1002 |
# File 'lib/optimist.rb', line 1002 def flag? ; true ; end |
#parse(_paramlist, neg_given) ⇒ Object
1003 1004 1005 |
# File 'lib/optimist.rb', line 1003 def parse(_paramlist, neg_given) return(self.name.to_s =~ /^no_/ ? neg_given : !neg_given) end |