Class: Slop::BoolOption

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

Overview

Cast the option argument to true or false. Override default_value to default to false instead of nil. This option type does not expect an argument.

Direct Known Subclasses

NullOption

Constant Summary

Constants inherited from Option

Option::DEFAULT_CONFIG

Instance Attribute Summary

Attributes inherited from Option

#block, #config, #count, #desc, #flags, #value

Instance Method Summary collapse

Methods inherited from Option

#ensure_call, #finish, #flag, #help?, #initialize, #key, #null?, #reset, #suppress_errors?, #tail, #tail?, #to_s

Constructor Details

This class inherits a constructor from Slop::Option

Instance Method Details

#call(_value) ⇒ Object



13
14
15
# File 'lib/slop/types.rb', line 13

def call(_value)
  true
end

#default_valueObject



17
18
19
# File 'lib/slop/types.rb', line 17

def default_value
  config[:default] || false
end

#expects_argument?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/slop/types.rb', line 21

def expects_argument?
  false
end