Class: NilClass

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

Overview

NilClass is extended with a few methods

Instance Method Summary (collapse)

Instance Method Details

- (FalseClass) and(other)

Boolean 'and' operation

Parameters:

Returns:

See Also:



236
237
238
239
240
241
242
243
# File 'lib/multiarray.rb', line 236

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

- (Object) conditional(a, b)

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:



269
270
271
# File 'lib/multiarray.rb', line 269

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

- (Object) if(&action)

Conditional operation

Parameters:

  • action (Proc)

    Action to perform if condition is true.

Returns:

  • (Object)

    The return value should be ignored.



278
279
# File 'lib/multiarray.rb', line 278

def if( &action )
end

- (Object) if_else(action1, action2)

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.



287
288
289
# File 'lib/multiarray.rb', line 287

def if_else( action1, action2 )
  action2.call
end

- (FalseClass) not

Boolean negation

Returns:

See Also:



225
226
227
# File 'lib/multiarray.rb', line 225

def not
   true
end

- (FalseClass, TrueClass) or(other)

Boolean 'or' operation

Parameters:

Returns:

See Also:



252
253
254
255
256
257
258
259
# File 'lib/multiarray.rb', line 252

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