Class: Axiom::Function

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium, Visitable
Defined in:
lib/axiom/function.rb,
lib/axiom/function/unary.rb,
lib/axiom/function/binary.rb,
lib/axiom/function/numeric.rb,
lib/axiom/function/predicate.rb,
lib/axiom/function/comparable.rb,
lib/axiom/function/connective.rb,
lib/axiom/function/proposition.rb,
lib/axiom/function/string/length.rb,
lib/axiom/function/numeric/modulo.rb,
lib/axiom/function/predicate/match.rb,
lib/axiom/function/numeric/absolute.rb,
lib/axiom/function/numeric/addition.rb,
lib/axiom/function/numeric/division.rb,
lib/axiom/function/numeric/unary_plus.rb,
lib/axiom/function/predicate/equality.rb,
lib/axiom/function/predicate/no_match.rb,
lib/axiom/function/connective/negation.rb,
lib/axiom/function/numeric/square_root.rb,
lib/axiom/function/numeric/subtraction.rb,
lib/axiom/function/numeric/unary_minus.rb,
lib/axiom/function/predicate/exclusion.rb,
lib/axiom/function/predicate/inclusion.rb,
lib/axiom/function/predicate/less_than.rb,
lib/axiom/function/predicate/enumerable.rb,
lib/axiom/function/predicate/inequality.rb,
lib/axiom/function/proposition/tautology.rb,
lib/axiom/function/connective/conjunction.rb,
lib/axiom/function/connective/disjunction.rb,
lib/axiom/function/numeric/exponentiation.rb,
lib/axiom/function/numeric/multiplication.rb,
lib/axiom/function/predicate/greater_than.rb,
lib/axiom/function/proposition/contradiction.rb,
lib/axiom/function/predicate/less_than_or_equal_to.rb,
lib/axiom/function/predicate/greater_than_or_equal_to.rb

Overview

Abstract base class for logical functions

Defined Under Namespace

Modules: Binary, Comparable, String, Unary Classes: Connective, Numeric, Predicate, Proposition

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Visitable

#accept

Class Method Details

.extract_value(operand, tuple) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extract the value from the operand or tuple

Parameters:

  • operand (Object, #call)

    the operand to extract the value from

  • tuple (Tuple)

    the tuple to pass in to the operand if it responds to #call

Returns:

  • (Object)


41
42
43
# File 'lib/axiom/function.rb', line 41

def self.extract_value(operand, tuple)
  operand.respond_to?(:call) ? operand.call(tuple) : operand
end

.rename_attributes(operand, aliases) ⇒ Function

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO:

simplify once Attribute#rename works the same as Function#rename

Rename the attribute(s) inside the function

Parameters:

Returns:



23
24
25
26
27
28
29
# File 'lib/axiom/function.rb', line 23

def self.rename_attributes(operand, aliases)
  if operand.respond_to?(:rename) && !operand.kind_of?(Attribute)
    operand.rename(aliases)
  else
    aliases[operand]
  end
end

Instance Method Details

#typeClass<Types::Object>

Return the function type

Examples:

type = function.type  # => Axiom::Types::Object

Returns:

  • (Class<Types::Object>)


53
54
55
# File 'lib/axiom/function.rb', line 53

def type
  self.class.type
end