Class: Trollop::BooleanOption

Inherits:
Option
  • Object
show all
Defined in:
lib/trollop.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.



756
757
758
759
# File 'lib/trollop.rb', line 756

def initialize
  super()
  @default = false
end

Instance Method Details

#flag?Boolean

Returns:

  • (Boolean)


760
# File 'lib/trollop.rb', line 760

def flag? ; true ; end

#parse(_paramlist, neg_given) ⇒ Object



761
762
763
# File 'lib/trollop.rb', line 761

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