Class: WordTree

Inherits:
Object
  • Object
show all
Defined in:
lib/tree/word_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWordTree

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_countObject

Returns the value of attribute line_count.



2
3
4
# File 'lib/tree/word_tree.rb', line 2

def line_count
  @line_count
end

#rootObject

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_treeObject



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