Class: Wongi::Engine::BetaTest

Inherits:
Object
  • Object
show all
Defined in:
lib/wongi-engine/beta/join_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, variable) ⇒ BetaTest

Returns a new instance of BetaTest.



6
7
8
9
# File 'lib/wongi-engine/beta/join_node.rb', line 6

def initialize(field, variable)
  @field = field
  @variable = variable
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



4
5
6
# File 'lib/wongi-engine/beta/join_node.rb', line 4

def field
  @field
end

#variableObject (readonly)

Returns the value of attribute variable.



4
5
6
# File 'lib/wongi-engine/beta/join_node.rb', line 4

def variable
  @variable
end

Instance Method Details

#equivalent?(other) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/wongi-engine/beta/join_node.rb', line 18

def equivalent?(other)
  other.field == field && other.variable == variable
end

#matches?(token, wme) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
# File 'lib/wongi-engine/beta/join_node.rb', line 11

def matches?(token, wme)
  assignment = token[variable]
  field = wme.send(self.field)
  # field.nil? ||
  !token.has_var?(variable) || field == assignment
end