Top Level Namespace

Defined Under Namespace

Modules: BigMath, Diggable, Enumerable, Kernel, Math Classes: Array, Complex, Enumerator, Exception, Float, FragileMethodChain, Hash, Integer, Iterator, MatchData, MaybeDelegator, Method, Module, Numeric, Object, Proc, Range, Regexp, String, Time

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_bObject



64
# File 'lib/mug/bool.rb', line 64

def nil.to_b; false; end

.to_boolObject



63
# File 'lib/mug/bool.rb', line 63

def nil.to_bool; false; end

Instance Method Details

#Bool(arg) ⇒ Boolean

Converts arg to a boolean (true or false).

Returns the truthiness of obj, as either true or false. This is functionally equivalent to calling !!arg.

Examples:

require 'mug/bool'
Bool(nil)    #=> false
Bool(0)      #=> true
Bool("hi")   #=> true

Parameters:

  • arg (Object)

    the object to convert

Returns:

  • (Boolean)

    the truthiness of arg



17
18
19
# File 'lib/mug/bool.rb', line 17

def Bool(arg)
  !!arg
end