Class: WordTree
- Inherits:
-
Object
- Object
- WordTree
- Defined in:
- lib/tree/word_tree.rb
Instance Attribute Summary collapse
-
#line_count ⇒ Object
Returns the value of attribute line_count.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #add(line) ⇒ Object
-
#initialize ⇒ WordTree
constructor
A new instance of WordTree.
- #to_tree ⇒ Object
- #truncate!(minimum) ⇒ Object
Constructor Details
#initialize ⇒ WordTree
Returns a new instance of WordTree.
4 5 6 7 |
# File 'lib/tree/word_tree.rb', line 4 def initialize @root = WordTreeNode.new @line_count = 0 end |
Instance Attribute Details
#line_count ⇒ Object
Returns the value of attribute line_count.
2 3 4 |
# File 'lib/tree/word_tree.rb', line 2 def line_count @line_count end |
#root ⇒ Object
Returns the value of attribute root.
2 3 4 |
# File 'lib/tree/word_tree.rb', line 2 def root @root end |
Instance Method Details
#add(line) ⇒ Object
9 10 11 12 |
# File 'lib/tree/word_tree.rb', line 9 def add(line) @line_count += 1 root.add(line, 0) end |
#to_tree ⇒ Object
18 19 20 |
# File 'lib/tree/word_tree.rb', line 18 def to_tree root.to_tree end |
#truncate!(minimum) ⇒ Object
14 15 16 |
# File 'lib/tree/word_tree.rb', line 14 def truncate!(minimum) root.truncate!(minimum) end |