Module: Axiom::Function::Unary
- Extended by:
- Callable
- Includes:
- Operation::Unary
- Included in:
- Connective::Negation, Numeric::Absolute, Numeric::SquareRoot, Numeric::UnaryMinus, Numeric::UnaryPlus, String::Length
- Defined in:
- lib/axiom/function/unary.rb
Overview
Mixin for unary functions
Defined Under Namespace
Modules: Callable, Invertible
Instance Attribute Summary
Attributes included from Operation::Unary
Instance Method Summary collapse
-
#call(tuple) ⇒ Boolean
Evaluate the unary connective using the tuple.
-
#rename(aliases) ⇒ self, Unary
Rename the contained attributes with the provided aliases.
-
#type ⇒ Class<Types::Numeric>
Return the type returned from #call.
Methods included from Callable
Methods included from Operation::Unary
Instance Method Details
#call(tuple) ⇒ Boolean
Evaluate the unary connective using the tuple
57 58 59 60 |
# File 'lib/axiom/function/unary.rb', line 57 def call(tuple) util = self.class util.call(util.extract_value(operand, tuple)) end |
#rename(aliases) ⇒ self, Unary
TODO:
handle case where operand is a literal
Rename the contained attributes with the provided aliases
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/axiom/function/unary.rb', line 78 def rename(aliases) util = self.class renamed_operand = util.rename_attributes(operand, aliases) if operand.equal?(renamed_operand) self else util.new(renamed_operand) end end |
#type ⇒ Class<Types::Numeric>
Return the type returned from #call
97 98 99 |
# File 'lib/axiom/function/unary.rb', line 97 def type Attribute.infer_type(operand) end |