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

#and(other) ⇒ FalseClass

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

#compilable?FalseClass, TrueClass

Check whether this term is compilable

Returns:



296
297
298
# File 'lib/multiarray.rb', line 296

def compilable?
  false
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:



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

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.



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

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.



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

def if_else( action1, action2 )
  action2.call
end

#notFalseClass

Boolean negation

Returns:

See Also:



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

def not
   true
end

#or(other) ⇒ FalseClass, TrueClass

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