Module: Flckr::Dict

Defined in:
lib/flckr/dict.rb

Constant Summary collapse

DEFAULT_DICT =
'/usr/share/dict/words'.freeze

Class Method Summary collapse

Class Method Details

.make_ten_words(words) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/flckr/dict.rb', line 8

def self.make_ten_words(words)
  ten_words = words.take(10)
  count = ten_words.count
  return ten_words if count == 10
  (10 - count).times { ten_words << Dict.random_line }
  ten_words
end

.random_lineObject



4
5
6
# File 'lib/flckr/dict.rb', line 4

def self.random_line
  File.readlines(DEFAULT_DICT).sample.strip
end