class WordsToImage::Dictionary

Public Class Methods

new(path) click to toggle source
# File lib/words_to_image/dictionary.rb, line 3
def initialize(path)
  @path = path
end

Public Instance Methods

get_word() click to toggle source
# File lib/words_to_image/dictionary.rb, line 7
def get_word
  words.delete(words.sample)
end

Private Instance Methods

read_content() click to toggle source
# File lib/words_to_image/dictionary.rb, line 16
def read_content
  contents = File.read(@path)
  contents.split
rescue => e
  raise IOError, "Dictionary file unreadable: #{e.message}"
end
words() click to toggle source
# File lib/words_to_image/dictionary.rb, line 12
def words
  @words ||= read_content
end