Class: LetterPressIsNotAsGoodAsBoggle::WordList

Inherits:
Object
  • Object
show all
Defined in:
lib/letter_press_is_not_as_good_as_boggle/word_list.rb,
lib/letter_press_is_not_as_good_as_boggle/word_list/node.rb,
lib/letter_press_is_not_as_good_as_boggle/word_list/searcher.rb

Defined Under Namespace

Classes: Node, Searcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(all_words = []) ⇒ WordList

Returns a new instance of WordList.



7
8
9
10
# File 'lib/letter_press_is_not_as_good_as_boggle/word_list.rb', line 7

def initialize(all_words=[])
  @root = Node.new ''
  all_words.each { |word| self << word }
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/letter_press_is_not_as_good_as_boggle/word_list.rb', line 5

def root
  @root
end

Instance Method Details

#<<(word) ⇒ Object



12
13
14
15
# File 'lib/letter_press_is_not_as_good_as_boggle/word_list.rb', line 12

def <<(word)
  root.add word.chars.to_a
  self
end

#wordsObject



17
18
19
# File 'lib/letter_press_is_not_as_good_as_boggle/word_list.rb', line 17

def words
  root.words
end