Class: KBS::Token
- Inherits:
-
Object
- Object
- KBS::Token
- Defined in:
- lib/kbs/token.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#fact ⇒ Object
Returns the value of attribute fact.
-
#node ⇒ Object
Returns the value of attribute node.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #facts ⇒ Object
- #fired? ⇒ Boolean
-
#initialize(parent, fact, node) ⇒ Token
constructor
A new instance of Token.
- #mark_fired! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parent, fact, node) ⇒ Token
Returns a new instance of Token.
7 8 9 10 11 12 13 |
# File 'lib/kbs/token.rb', line 7 def initialize(parent, fact, node) @parent = parent @fact = fact @node = node @children = [] @fired = false end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/kbs/token.rb', line 5 def children @children end |
#fact ⇒ Object
Returns the value of attribute fact.
5 6 7 |
# File 'lib/kbs/token.rb', line 5 def fact @fact end |
#node ⇒ Object
Returns the value of attribute node.
5 6 7 |
# File 'lib/kbs/token.rb', line 5 def node @node end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/kbs/token.rb', line 5 def parent @parent end |
Instance Method Details
#facts ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/kbs/token.rb', line 15 def facts facts = [] token = self while token facts.unshift(token.fact) if token.fact token = token.parent end facts end |
#fired? ⇒ Boolean
29 30 31 |
# File 'lib/kbs/token.rb', line 29 def fired? @fired end |
#mark_fired! ⇒ Object
33 34 35 |
# File 'lib/kbs/token.rb', line 33 def mark_fired! @fired = true end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/kbs/token.rb', line 25 def to_s "Token(#{facts.map(&:to_s).join(', ')})" end |