Class: FalseClass

Inherits:
Object show all
Defined in:
lib/multiarray.rb

Overview

FalseClass is extended with a few methods

See Also:

  • TrueClass

Instance Method Summary collapse

Instance Method Details

#and(other) ⇒ FalseClass

Boolean ‘and’ operation

Parameters:

Returns:

See Also:



332
333
334
335
336
337
338
339
# File 'lib/multiarray.rb', line 332

def and( other )
  unless other.matched?
    self
  else
    x, y = other.coerce self
    x.and y
  end
end

#conditional(a, b) ⇒ Object

Boolean select operation

Parameters:

  • a (Object)

    Object to select if self is neither false nor nil.

  • b (Object)

    Object to select if self is false or nil.

Returns:

See Also:



365
366
367
# File 'lib/multiarray.rb', line 365

def conditional( a, b )
  b.is_a?( Proc ) ? b.call : b
end

#if(&action) ⇒ Object

Conditional operation

Parameters:

  • action (Proc)

    Action to perform if condition is true.

Returns:

  • (Object)

    The return value should be ignored.



374
375
# File 'lib/multiarray.rb', line 374

def if( &action )
end

#if_else(action1, action2) ⇒ Object

Conditional operation

Parameters:

  • action1 (Proc)

    Action to perform if condition is true.

  • action2 (Proc)

    Action to perform if condition is false.

Returns:

  • (Object)

    The return value should be ignored.



383
384
385
# File 'lib/multiarray.rb', line 383

def if_else( action1, action2 )
  action2.call
end

#notFalseClass

Boolean negation

Returns:

See Also:



321
322
323
# File 'lib/multiarray.rb', line 321

def not
  true
end

#or(other) ⇒ FalseClass, TrueClass

Boolean ‘or’ operation

Parameters:

Returns:

See Also:



348
349
350
351
352
353
354
355
# File 'lib/multiarray.rb', line 348

def or( other )
  unless other.matched?
    other
  else
    x, y = other.coerce self
    x.or y
  end
end