Class: Object

Inherits:
BasicObject
Defined in:
lib/multiarray.rb

Overview

Object is extended with a few methods

Instance Method Summary collapse

Instance Method Details

#and(other) ⇒ FalseClass, TrueClass

Boolean ‘and’ operation

Parameters:

Returns:

See Also:



102
103
104
105
106
107
108
109
# File 'lib/multiarray.rb', line 102

def and( other )
  unless other.is_a? Hornetseye::Node
    other
  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:



171
172
173
# File 'lib/multiarray.rb', line 171

def conditional( a, b )
  a
end

#eq(other) ⇒ FalseClass, ...

Element-wise equal operator

The method calls self == other unless other is of type Hornetseye::Node. In that case an element-wise comparison using Hornetseye::Node#eq is performed after coercion.

Returns:

See Also:



136
137
138
139
140
141
142
143
# File 'lib/multiarray.rb', line 136

def eq( other )
  unless other.is_a? Hornetseye::Node
    self == other
  else
    x, y = other.coerce self
    x.eq y
  end
end

#instance_exec(*arguments, &block) ⇒ Object

Object#instance_exec is defined if it does not exist already



79
80
81
# File 'lib/multiarray.rb', line 79

def instance_exec( *arguments, &block )
  block.bind( self )[ *arguments ]
end

#ne(other) ⇒ FalseClass, ...

Element-wise not-equal operator

The method calls ( self == other ).not unless other is of type Hornetseye::Node. In that case an element-wise comparison using Hornetseye::Node#ne is performed after coercion.

Returns:

See Also:



154
155
156
157
158
159
160
161
# File 'lib/multiarray.rb', line 154

def ne( other )
  unless other.is_a? Hornetseye::Node
    ( self == other ).not
  else
    x, y = other.coerce self
    x.ne y
  end
end

#notFalseClass

Boolean negation

Returns:

See Also:



91
92
93
# File 'lib/multiarray.rb', line 91

def not
   false
end

#or(other) ⇒ TrueClass

Boolean ‘or’ operation

Parameters:

Returns:

  • (TrueClass)

    Returns true.

See Also:



118
119
120
121
122
123
124
125
# File 'lib/multiarray.rb', line 118

def or( other )
  unless other.is_a? Hornetseye::Node
    self
  else
    x, y = other.coerce self
    x.or y
  end
end