Class: Object
- Inherits:
- BasicObject
- Defined in:
- docs/multiarray/lib/multiarray.rb
Overview
Object
is extended with a few methods
Instance Method Summary collapse
-
#and(other) ⇒ FalseClass, TrueClass
Boolean ‘and’ operation.
-
#conditional(a, b) ⇒ Object
Boolean select operation.
-
#eq(other) ⇒ FalseClass, ...
Element-wise equal operator.
-
#if(&action) ⇒ Object
Conditional operation.
-
#if_else(action1, action2) ⇒ Object
Conditional operation.
- #matched? ⇒ Boolean
-
#ne(other) ⇒ FalseClass, ...
Element-wise not-equal operator.
-
#not ⇒ FalseClass
Boolean negation.
-
#or(other) ⇒ TrueClass
Boolean ‘or’ operation.
Instance Method Details
#and(other) ⇒ FalseClass, TrueClass
Boolean ‘and’ operation
122 123 124 125 126 127 128 129 |
# File 'docs/multiarray/lib/multiarray.rb', line 122 def and( other ) unless other.matched? other else x, y = other.coerce self x.and y end end |
#conditional(a, b) ⇒ Object
Boolean select operation
191 192 193 |
# File 'docs/multiarray/lib/multiarray.rb', line 191 def conditional( a, b ) a.is_a?( Proc ) ? a.call : 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.
156 157 158 159 160 161 162 163 |
# File 'docs/multiarray/lib/multiarray.rb', line 156 def eq( other ) unless other.matched? self == other else x, y = other.coerce self x.eq y end end |
#if(&action) ⇒ Object
Conditional operation
200 201 202 |
# File 'docs/multiarray/lib/multiarray.rb', line 200 def if( &action ) action.call end |
#if_else(action1, action2) ⇒ Object
Conditional operation
210 211 212 |
# File 'docs/multiarray/lib/multiarray.rb', line 210 def if_else( action1, action2 ) action1.call end |
#matched? ⇒ Boolean
101 102 103 |
# File 'docs/multiarray/lib/multiarray.rb', line 101 def matched? false 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.
174 175 176 177 178 179 180 181 |
# File 'docs/multiarray/lib/multiarray.rb', line 174 def ne( other ) unless other.matched? ( self == other ).not else x, y = other.coerce self x.ne y end end |
#not ⇒ FalseClass
Boolean negation
111 112 113 |
# File 'docs/multiarray/lib/multiarray.rb', line 111 def not false end |
#or(other) ⇒ TrueClass
Boolean ‘or’ operation
138 139 140 141 142 143 144 145 |
# File 'docs/multiarray/lib/multiarray.rb', line 138 def or( other ) unless other.matched? self else x, y = other.coerce self x.or y end end |