Module: BooleanTypecast

Included in:
Object
Defined in:
lib/boolean_typecast.rb,
lib/boolean_typecast/version.rb

Overview

Type conversions from anything to true/false

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#to_bool?Boolean

Examples:

True values

true.to_bool?  #=> true
''.to_bool?    #=> true
0.to_bool?     #=> true
{}.to_bool?    #=> true

False values

false.to_bool? #=> false
nil.to_bool?   #=> false

Returns:

  • (Boolean)


14
15
16
# File 'lib/boolean_typecast.rb', line 14

def to_bool?
  !!self
end