Class: Optimist::BooleanOption

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

Instance Method Summary collapse

Methods inherited from Option

#array_default?, #callback, create, #desc, #description_with_default, #educate, #multi, #multi_arg?, #opts, #opts=, register_alias, #required?, #short?, #single_arg?, #type_format

Constructor Details

#initializeBooleanOption

Returns a new instance of BooleanOption.



762
763
764
765
# File 'lib/optimist.rb', line 762

def initialize
  super()
  @default = false
end

Instance Method Details

#flag?Boolean

Returns:

  • (Boolean)


766
# File 'lib/optimist.rb', line 766

def flag? ; true ; end

#parse(_paramlist, neg_given) ⇒ Object



767
768
769
# File 'lib/optimist.rb', line 767

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