Class: Linotype::Dictionary
- Inherits:
-
Object
- Object
- Linotype::Dictionary
- Defined in:
- lib/linotype/dictionary/dictionary.rb
Instance Attribute Summary collapse
-
#words ⇒ Object
Returns the value of attribute words.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Dictionary
constructor
A new instance of Dictionary.
- #valid?(word) ⇒ Boolean
- #words_path ⇒ Object
Constructor Details
#initialize ⇒ Dictionary
Returns a new instance of Dictionary.
14 15 16 |
# File 'lib/linotype/dictionary/dictionary.rb', line 14 def initialize @words = Set.new(File.open(words_path).readlines.collect { |word| word.upcase.chomp }) end |
Instance Attribute Details
#words ⇒ Object
Returns the value of attribute words.
12 13 14 |
# File 'lib/linotype/dictionary/dictionary.rb', line 12 def words @words end |
Class Method Details
.loaded ⇒ Object
7 8 9 |
# File 'lib/linotype/dictionary/dictionary.rb', line 7 def loaded @loaded ||= new end |
Instance Method Details
#valid?(word) ⇒ Boolean
22 23 24 |
# File 'lib/linotype/dictionary/dictionary.rb', line 22 def valid?(word) words.include?(word.upcase) end |
#words_path ⇒ Object
18 19 20 |
# File 'lib/linotype/dictionary/dictionary.rb', line 18 def words_path File.dirname(__FILE__) + "/words.txt" end |