Class: Recheck::Optimist::BooleanOption

Inherits:
Option
  • Object
show all
Defined in:
lib/recheck/vendor/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, #permitted_response, #short

Instance Method Summary collapse

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

#initializeBooleanOption

Returns a new instance of BooleanOption.



1029
1030
1031
1032
# File 'lib/recheck/vendor/optimist.rb', line 1029

def initialize
  super
  @default = false
end

Instance Method Details

#flag?Boolean

Returns:

  • (Boolean)


1034
1035
1036
# File 'lib/recheck/vendor/optimist.rb', line 1034

def flag?
  true
end

#parse(_paramlist, neg_given) ⇒ Object



1038
1039
1040
# File 'lib/recheck/vendor/optimist.rb', line 1038

def parse(_paramlist, neg_given)
  (/^no_/.match?(name.to_s) ? neg_given : !neg_given)
end