Class: Ruleby::Core::CompositePattern

Inherits:
Pattern
  • Object
show all
Defined in:
lib/core/patterns.rb

Overview

A composite pattern represents a logical conjunction of two patterns. The inference engine interprets this differently from an ObjectPattern because it simply aggregates patterns.

Direct Known Subclasses

AndPattern, OrPattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left_pattern, right_pattern) ⇒ CompositePattern

Returns a new instance of CompositePattern.



75
76
77
78
# File 'lib/core/patterns.rb', line 75

def initialize(left_pattern, right_pattern)
  @left_pattern = left_pattern
  @right_pattern = right_pattern
end

Instance Attribute Details

#left_patternObject (readonly)

Returns the value of attribute left_pattern.



72
73
74
# File 'lib/core/patterns.rb', line 72

def left_pattern
  @left_pattern
end

#right_patternObject (readonly)

Returns the value of attribute right_pattern.



73
74
75
# File 'lib/core/patterns.rb', line 73

def right_pattern
  @right_pattern
end

Instance Method Details

#atomsObject



80
81
82
83
84
85
# File 'lib/core/patterns.rb', line 80

def atoms
  atoms = []
  atoms.push @left_pattern.atoms
  atoms.push @right_pattern.atoms
  return atoms
end