Method: Kernel#to_b
- Defined in:
- lib/core/facets/boolean.rb
#to_b ⇒ Object
Boolean conversion for not being nil or false. Other classes may redefine this to suite the particular need.
"yes".to_b #=> true
"abc".to_b #=> false
true.to_b #=> true
false.to_b #=> false
nil.to_b #=> false
CREDIT: Ara T. Howard, Trans
17 18 19 |
# File 'lib/core/facets/boolean.rb', line 17 def to_b self ? true : false end |