Class: Wongi::Engine::WME
- Inherits:
-
Struct
- Object
- Struct
- Wongi::Engine::WME
- Defined in:
- lib/wongi-engine/wme.rb
Instance Attribute Summary collapse
-
#alphas ⇒ Object
readonly
Returns the value of attribute alphas.
-
#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.
-
#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.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #=~(template) ⇒ Object
- #deleted? ⇒ Boolean
- #destroy ⇒ 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
- #manual? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(s, p, o, r = nil) ⇒ WME
Returns a new instance of WME.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wongi-engine/wme.rb', line 10 def initialize s, p, o, r = nil @deleted = false @alphas = [] @tokens = [] @generating_tokens = [] @neg_join_results = [] @opt_join_results = [] @rete = r if r super( r.import(s), r.import(p), r.import(o) ) else super( s, p, o ) end end |
Instance Attribute Details
#alphas ⇒ Object (readonly)
Returns the value of attribute alphas.
7 8 9 |
# File 'lib/wongi-engine/wme.rb', line 7 def alphas @alphas end |
#generating_tokens ⇒ Object (readonly)
Returns the value of attribute generating_tokens.
7 8 9 |
# File 'lib/wongi-engine/wme.rb', line 7 def @generating_tokens end |
#neg_join_results ⇒ Object (readonly)
Returns the value of attribute neg_join_results.
8 9 10 |
# File 'lib/wongi-engine/wme.rb', line 8 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.
8 9 10 |
# File 'lib/wongi-engine/wme.rb', line 8 def opt_join_results @opt_join_results 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.
5 6 7 |
# File 'lib/wongi-engine/wme.rb', line 5 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 |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/wongi-engine/wme.rb', line 7 def tokens @tokens end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/wongi-engine/wme.rb', line 37 def == other subject == other.subject && predicate == other.predicate && object == other.object end |
#=~(template) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/wongi-engine/wme.rb', line 41 def =~ template raise "Cannot match a WME against a #{template.class}" unless Template === template result = match_member( template, :subject ) & match_member( template, :predicate ) & match_member( template, :object ) if result.match? result end end |
#deleted? ⇒ Boolean
57 58 59 |
# File 'lib/wongi-engine/wme.rb', line 57 def deleted? @deleted end |
#destroy ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/wongi-engine/wme.rb', line 61 def destroy @deleted = true alphas.each { |alpha| alpha.remove self }.clear while tokens.first tokens.first.delete # => will remove itself from the array end destroy_neg_join_results destroy_opt_join_results end |
#dup ⇒ Object
33 34 35 |
# File 'lib/wongi-engine/wme.rb', line 33 def dup self.class.new subject, predicate, object, rete end |
#generated? ⇒ Boolean
53 54 55 |
# File 'lib/wongi-engine/wme.rb', line 53 def generated? !manual? end |
#hash ⇒ Object
82 83 84 |
# File 'lib/wongi-engine/wme.rb', line 82 def hash @hash ||= array_form.map( &:hash ).hash end |
#import_into(r) ⇒ Object
29 30 31 |
# File 'lib/wongi-engine/wme.rb', line 29 def import_into r self.class.new subject, predicate, object, r end |
#inspect ⇒ Object
74 75 76 |
# File 'lib/wongi-engine/wme.rb', line 74 def inspect "<WME #{subject.inspect} #{predicate.inspect} #{object.inspect}>" end |
#manual? ⇒ Boolean
49 50 51 |
# File 'lib/wongi-engine/wme.rb', line 49 def manual? .empty? end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/wongi-engine/wme.rb', line 78 def to_s inspect end |