Class: PixelFontTrieOCR::Trie::Node
- Inherits:
-
Object
- Object
- PixelFontTrieOCR::Trie::Node
- Defined in:
- lib/pixel_font_trie_ocr/trie/node.rb
Instance Attribute Summary collapse
-
#character ⇒ Object
Returns the value of attribute character.
-
#children ⇒ Object
Returns the value of attribute children.
Instance Method Summary collapse
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #leaf? ⇒ Boolean
- #match(columns, index) ⇒ Object
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
8 9 10 11 |
# File 'lib/pixel_font_trie_ocr/trie/node.rb', line 8 def initialize @children = {} @character = nil end |
Instance Attribute Details
#character ⇒ Object
Returns the value of attribute character.
6 7 8 |
# File 'lib/pixel_font_trie_ocr/trie/node.rb', line 6 def character @character end |
#children ⇒ Object
Returns the value of attribute children.
6 7 8 |
# File 'lib/pixel_font_trie_ocr/trie/node.rb', line 6 def children @children end |
Instance Method Details
#leaf? ⇒ Boolean
13 14 15 |
# File 'lib/pixel_font_trie_ocr/trie/node.rb', line 13 def leaf? children.empty? end |
#match(columns, index) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/pixel_font_trie_ocr/trie/node.rb', line 17 def match(columns, index) if index < columns.length child_char, child_idx = children[columns[index]]&.match(columns, index + 1) return [child_char, child_idx] if child_char end [character, index] end |