Class: FlickrCollage::Dictionary
- Inherits:
-
Object
- Object
- FlickrCollage::Dictionary
- Defined in:
- lib/FlickrCollage.rb
Constant Summary
- DICT_FILE =
"/usr/share/dict/words"
Instance Attribute Summary collapse
-
#words ⇒ Array
All words at dictionary file.
Instance Method Summary collapse
-
#get_word ⇒ String
Get random word from Dictionary file.
-
#initialize(opts = {}) ⇒ Dictionary
constructor
A new instance of Dictionary.
Constructor Details
#initialize(opts = {}) ⇒ Dictionary
Returns a new instance of Dictionary
22 23 24 25 26 27 |
# File 'lib/FlickrCollage.rb', line 22 def initialize(opts = {}) opts[:file] ||= DICT_FILE @words = File.read(opts[:file]).lines.select do |line| (4..9).cover?(line.strip.size) end end |
Instance Attribute Details
#words ⇒ Array
Returns All words at dictionary file
20 21 22 |
# File 'lib/FlickrCollage.rb', line 20 def words @words end |
Instance Method Details
#get_word ⇒ String
Get random word from Dictionary file
32 33 34 |
# File 'lib/FlickrCollage.rb', line 32 def get_word @words.sample.strip end |