Class: Optimist::BooleanOption

Inherits:
Option
  • Object
show all
Defined in:
lib/optimist_with_insert_blanks.rb

Overview

Flag option. Has no arguments. Can be negated with “no-”.

Instance Attribute Summary

Attributes inherited from Option

#default, #long, #multi_given, #name, #short

Instance Method Summary collapse

Methods inherited from Option

#array_default?, #callback, create, #desc, #description_with_default, #educate, 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

#initializeBooleanOption

Returns a new instance of BooleanOption.



885
886
887
888
# File 'lib/optimist_with_insert_blanks.rb', line 885

def initialize
  super()
  @default = false
end

Instance Method Details

#flag?Boolean

Returns:

  • (Boolean)


890
891
892
# File 'lib/optimist_with_insert_blanks.rb', line 890

def flag?
  true
end

#parse(_paramlist, neg_given) ⇒ Object



894
895
896
# File 'lib/optimist_with_insert_blanks.rb', line 894

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