Class: Object
- Inherits:
- BasicObject
- Defined in:
- 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.
-
#instance_exec(*arguments, &block) ⇒ Object
Object#instance_exec is defined if it does not exist already.
- #matched? ⇒ Boolean
-
#ne(other) ⇒ FalseClass, ...
Element-wise not-equal operator.
-
#not ⇒ FalseClass
Boolean negation.
-
#or(other) ⇒ TrueClass
Boolean ‘or’ operation.
- #sexp ⇒ Object
- #sexp? ⇒ Boolean
Instance Method Details
#and(other) ⇒ FalseClass, TrueClass
Boolean ‘and’ operation
130 131 132 133 134 135 136 137 |
# File 'lib/multiarray.rb', line 130 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
199 200 201 |
# File 'lib/multiarray.rb', line 199 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.
164 165 166 167 168 169 170 171 |
# File 'lib/multiarray.rb', line 164 def eq( other ) unless other.matched? self == other else x, y = other.coerce self x.eq y end end |
#if(&action) ⇒ Object
Conditional operation
208 209 210 |
# File 'lib/multiarray.rb', line 208 def if( &action ) action.call end |
#if_else(action1, action2) ⇒ Object
Conditional operation
218 219 220 |
# File 'lib/multiarray.rb', line 218 def if_else( action1, action2 ) action1.call end |
#instance_exec(*arguments, &block) ⇒ Object
Object#instance_exec is defined if it does not exist already
95 96 97 |
# File 'lib/multiarray.rb', line 95 def instance_exec( *arguments, &block ) block.bind( self )[ *arguments ] end |
#matched? ⇒ Boolean
109 110 111 |
# File 'lib/multiarray.rb', line 109 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.
182 183 184 185 186 187 188 189 |
# File 'lib/multiarray.rb', line 182 def ne( other ) unless other.matched? ( self == other ).not else x, y = other.coerce self x.ne y end end |
#not ⇒ FalseClass
Boolean negation
119 120 121 |
# File 'lib/multiarray.rb', line 119 def not false end |
#or(other) ⇒ TrueClass
Boolean ‘or’ operation
146 147 148 149 150 151 152 153 |
# File 'lib/multiarray.rb', line 146 def or( other ) unless other.matched? self else x, y = other.coerce self x.or y end end |
#sexp ⇒ Object
101 102 103 |
# File 'lib/multiarray.rb', line 101 def sexp self end |
#sexp? ⇒ Boolean
105 106 107 |
# File 'lib/multiarray.rb', line 105 def sexp? false end |