Sha256: 21b8113f9813334eb74855fb188a8298716cd168a1bc69aaf9d030ffbcd25c92

Contents?: true

Size: 441 Bytes

Versions: 6

Compression:

Stored size: 441 Bytes

Contents

require 'set'

module Linotype
  class Dictionary
    
    class << self
      def loaded
        @loaded ||= new
      end
    end
    
    attr_accessor :words

    def initialize
      @words = Set.new(File.open(words_path).readlines.collect { |word| word.upcase.chomp })
    end
    
    def words_path
      File.dirname(__FILE__) + "/words.txt"
    end
    
    def valid?(word)
      words.include?(word.upcase)
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
linotype-0.0.6 lib/linotype/dictionary/dictionary.rb
linotype-0.0.5 lib/linotype/dictionary/dictionary.rb
linotype-0.0.4 lib/linotype/dictionary/dictionary.rb
linotype-0.0.3 lib/linotype/dictionary/dictionary.rb
linotype-0.0.2 lib/linotype/dictionary/dictionary.rb
linotype-0.0.1 lib/linotype/dictionary/dictionary.rb