Sha256: 1f65352d14311d04aa7458c1c005b627b28c277b2e2f118d9e9cd81be7c7b2e5

Contents?: true

Size: 389 Bytes

Versions: 2

Compression:

Stored size: 389 Bytes

Contents

module WordsToImage
  class Dictionary
    def initialize(path)
      @path = path
    end

    def get_word
      words.delete(words.sample)
    end

    private
    def words
      @words ||= read_content
    end

    def read_content
      contents = File.read(@path)
      contents.split
    rescue => e
      raise IOError, "Dictionary file unreadable: #{e.message}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
words_to_image-0.0.3 lib/words_to_image/dictionary.rb
words_to_image-0.0.2 lib/words_to_image/dictionary.rb