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:



244
245
246
247
248
249
250
251
# File 'lib/multiarray.rb', line 244

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:



304
305
306
# File 'lib/multiarray.rb', line 304

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:



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

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.



286
287
# File 'lib/multiarray.rb', line 286

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.



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

def if_else( action1, action2 )
  action2.call
end

#notFalseClass

Boolean negation

Returns:

See Also:



233
234
235
# File 'lib/multiarray.rb', line 233

def not
   true
end

#or(other) ⇒ FalseClass, TrueClass

Boolean ‘or’ operation

Parameters:

Returns:

See Also:



260
261
262
263
264
265
266
267
# File 'lib/multiarray.rb', line 260

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