Module: Axiom::Function::Binary

Includes:
Operation::Binary
Included in:
Connective::Conjunction, Connective::Disjunction, Numeric::Binary, Predicate
Defined in:
lib/axiom/function/binary.rb

Overview

Mixin for binary functions

Defined Under Namespace

Modules: Invertible

Instance Attribute Summary

Attributes included from Operation::Binary

#left, #right

Instance Method Summary collapse

Methods included from Operation::Binary

#initialize

Instance Method Details

#call(tuple) ⇒ Boolean

Evaluate the binary function using the tuple

Examples:

binary.call(tuple)  # => true or false

Parameters:

  • tuple (Tuple)

    the tuple to pass to #call in the left and right operands

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/axiom/function/binary.rb', line 21

def call(tuple)
  util = self.class
  util.call(
    util.extract_value(left,  tuple),
    util.extract_value(right, tuple)
  )
end

#rename(aliases) ⇒ self, Binary

TODO:

handle case where left/right are literals

Rename the contained attributes with the provided aliases

Examples:

renamed = binary.rename(aliases)

Parameters:

Returns:

  • (self)

    if the left and right operands are not renamed

  • (Binary)

    if the left or right operand is renamed



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/axiom/function/binary.rb', line 45

def rename(aliases)
  util          = self.class
  renamed_left  = util.rename_attributes(left,  aliases)
  renamed_right = util.rename_attributes(right, aliases)

  if left.equal?(renamed_left) && right.equal?(renamed_right)
    self
  else
    util.new(renamed_left, renamed_right)
  end
end