Class: Wongi::Engine::WME
- Inherits:
-
Struct
- Object
- Struct
- Wongi::Engine::WME
- Defined in:
- lib/wongi-engine/wme.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#subject ⇒ Object
Returns the value of attribute subject.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object
2 3 4 |
# File 'lib/wongi-engine/wme.rb', line 2 def object @object end |
#predicate ⇒ Object
Returns the value of attribute predicate
2 3 4 |
# File 'lib/wongi-engine/wme.rb', line 2 def predicate @predicate end |
#subject ⇒ Object
Returns the value of attribute subject
2 3 4 |
# File 'lib/wongi-engine/wme.rb', line 2 def subject @subject end |
Class Method Details
.from_concrete_template(template) ⇒ Object
3 4 5 6 7 |
# File 'lib/wongi-engine/wme.rb', line 3 def self.from_concrete_template(template) raise "template #{template} is not concrete" unless template.concrete? new(template.subject, template.predicate, template.object) end |
Instance Method Details
#=~(template) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/wongi-engine/wme.rb', line 14 def =~(template) raise Wongi::Engine::Error, "Cannot match a WME against a #{template.class}" unless template.is_a?(Template) result = match_member(subject, template.subject) & match_member(predicate, template.predicate) & match_member(object, template.object) result if result.match? end |
#dup ⇒ Object
9 10 11 |
# File 'lib/wongi-engine/wme.rb', line 9 def dup self.class.new(subject, predicate, object) end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/wongi-engine/wme.rb', line 21 def inspect "{#{subject.inspect} #{predicate.inspect} #{object.inspect}}" end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/wongi-engine/wme.rb', line 25 def to_s inspect end |