class Upwords::Dictionary

Public Class Methods

import(filepath) click to toggle source
# File lib/upwords/dictionary.rb, line 8
def self.import(filepath)
  dict = Dictionary.new
  File.foreach(filepath) do |line|
    dict << line.chomp
  end
  dict
end
new(words = []) click to toggle source
# File lib/upwords/dictionary.rb, line 4
def initialize(words = [])
  @legal_words = Set.new(words.map {|w| w.upcase})
end

Public Instance Methods

<<(word)
Alias for: add_word
add_word(word) click to toggle source
# File lib/upwords/dictionary.rb, line 20
def add_word word
  @legal_words.add? (word.upcase)
end
Also aliased as: <<
remove_word(word) click to toggle source
# File lib/upwords/dictionary.rb, line 26
def remove_word word
  @legal_words.delete? (word.upcase)
end