Class: Wongi::Engine::WME
- Inherits:
-
Struct
- Object
- Struct
- Wongi::Engine::WME
- Includes:
- CoreExt
- Defined in:
- lib/wongi-engine/wme.rb
Instance Attribute Summary collapse
-
#generating_tokens ⇒ Object
readonly
Returns the value of attribute generating_tokens.
-
#neg_join_results ⇒ Object
readonly
Returns the value of attribute neg_join_results.
-
#object ⇒ Object
Returns the value of attribute object.
-
#opt_join_results ⇒ Object
readonly
Returns the value of attribute opt_join_results.
-
#overlay ⇒ Object
Returns the value of attribute overlay.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#rete ⇒ Object
readonly
Returns the value of attribute rete.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #=~(template) ⇒ Object
- #dup ⇒ Object
- #generated? ⇒ Boolean
- #hash ⇒ Object
- #import_into(r) ⇒ Object
-
#initialize(s, p, o, r = nil) ⇒ WME
constructor
A new instance of WME.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods included from CoreExt
Constructor Details
#initialize(s, p, o, r = nil) ⇒ WME
Returns a new instance of WME.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wongi-engine/wme.rb', line 15 def initialize s, p, o, r = nil manual! @deleted = false @alphas = [] = [] @neg_join_results = [] @opt_join_results = [] @rete = r # TODO: reintroduce Network#import when bringing back RDF support super( s, p, o ) end |
Instance Attribute Details
#generating_tokens ⇒ Object (readonly)
Returns the value of attribute generating_tokens.
9 10 11 |
# File 'lib/wongi-engine/wme.rb', line 9 def end |
#neg_join_results ⇒ Object (readonly)
Returns the value of attribute neg_join_results.
10 11 12 |
# File 'lib/wongi-engine/wme.rb', line 10 def neg_join_results @neg_join_results end |
#object ⇒ Object
Returns the value of attribute object
3 4 5 |
# File 'lib/wongi-engine/wme.rb', line 3 def object @object end |
#opt_join_results ⇒ Object (readonly)
Returns the value of attribute opt_join_results.
10 11 12 |
# File 'lib/wongi-engine/wme.rb', line 10 def opt_join_results @opt_join_results end |
#overlay ⇒ Object
Returns the value of attribute overlay.
11 12 13 |
# File 'lib/wongi-engine/wme.rb', line 11 def end |
#predicate ⇒ Object
Returns the value of attribute predicate
3 4 5 |
# File 'lib/wongi-engine/wme.rb', line 3 def predicate @predicate end |
#rete ⇒ Object (readonly)
Returns the value of attribute rete.
7 8 9 |
# File 'lib/wongi-engine/wme.rb', line 7 def rete @rete end |
#subject ⇒ Object
Returns the value of attribute subject
3 4 5 |
# File 'lib/wongi-engine/wme.rb', line 3 def subject @subject end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/wongi-engine/wme.rb', line 46 def == other subject == other.subject && predicate == other.predicate && object == other.object end |
#=~(template) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/wongi-engine/wme.rb', line 50 def =~ template raise Wongi::Engine::Error, "Cannot match a WME against a #{template.class}" unless Template === template result = match_member( self.subject, template.subject ) & match_member( self.predicate, template.predicate ) & match_member( self.object, template.object ) if result.match? result end end |
#dup ⇒ Object
39 40 41 42 43 44 |
# File 'lib/wongi-engine/wme.rb', line 39 def dup self.class.new( subject, predicate, object, rete ).tap do |wme| wme. = wme.manual = self.manual? end end |
#generated? ⇒ Boolean
58 59 60 |
# File 'lib/wongi-engine/wme.rb', line 58 def generated? !.empty? end |
#hash ⇒ Object
70 71 72 |
# File 'lib/wongi-engine/wme.rb', line 70 def hash @hash ||= [subject.hash, predicate.hash, object.hash].hash end |
#import_into(r) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/wongi-engine/wme.rb', line 32 def import_into r self.class.new( subject, predicate, object, r ).tap do |wme| wme. = wme.manual = self.manual? end end |
#inspect ⇒ Object
62 63 64 |
# File 'lib/wongi-engine/wme.rb', line 62 def inspect "{#{subject.inspect} #{predicate.inspect} #{object.inspect}}" end |
#to_s ⇒ Object
66 67 68 |
# File 'lib/wongi-engine/wme.rb', line 66 def to_s inspect end |