Module: WordSalad

Defined in:
lib/word_salad.rb

Overview

This module generates random English words

Class Method Summary collapse

Class Method Details

.dictionaryObject

the dictionary as a File object



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

def dictionary
  @dictionary ||=
    File.open(File.join(File.dirname(__FILE__), 'word_salad/dictionary'))
end

.dictionary_path=(filename) ⇒ Object



12
13
14
# File 'lib/word_salad.rb', line 12

def dictionary_path=(filename)
  @dictionary = filename
end

.sizeObject

the number of words in the dictionary



20
21
22
# File 'lib/word_salad.rb', line 20

def size
  @size ||= words.size
end

.wordsObject

all the words in the dictionary



17
# File 'lib/word_salad.rb', line 17

def words = File.readlines(dictionary, chomp: true)