Class: StringTree::Item
- Inherits:
-
Object
- Object
- StringTree::Item
- Defined in:
- lib/stringtree/item.rb
Overview
Represents an individual tokenized item in a dataset, i.e. A match, its offset and its terminator node
Instance Attribute Summary collapse
-
#match ⇒ Object
The match itself.
-
#node ⇒ Object
The terminating node of the match.
-
#offset ⇒ Object
The offset of the Item in the dataset, in chars.
Instance Method Summary collapse
-
#initialize(offset, match, node = nil) ⇒ Item
constructor
Create a new Item with the specifid offset,match and optionally, node.
-
#match? ⇒ Boolean
Returns true if this is a match.
-
#value ⇒ Object
Returns the value of the match if not nil.
Constructor Details
#initialize(offset, match, node = nil) ⇒ Item
Create a new Item with the specifid offset,match and optionally, node.
12 13 14 15 16 |
# File 'lib/stringtree/item.rb', line 12 def initialize(offset, match, node = nil) @offset = offset @match = match @node = node end |
Instance Attribute Details
#match ⇒ Object
The match itself
7 8 9 |
# File 'lib/stringtree/item.rb', line 7 def match @match end |
#node ⇒ Object
The terminating node of the match.
9 10 11 |
# File 'lib/stringtree/item.rb', line 9 def node @node end |
#offset ⇒ Object
The offset of the Item in the dataset, in chars
5 6 7 |
# File 'lib/stringtree/item.rb', line 5 def offset @offset end |
Instance Method Details
#match? ⇒ Boolean
Returns true if this is a match.
19 20 21 |
# File 'lib/stringtree/item.rb', line 19 def match? @match end |
#value ⇒ Object
Returns the value of the match if not nil
24 25 26 |
# File 'lib/stringtree/item.rb', line 24 def value @node.value unless @node.nil? end |