Sha256: b237c9270fc55c30604579c32fe532011fa923caa82913f42f74a1e98e1486ee

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

require 'singleton'
require "LittleWeasel/version"

module LittleWeasel

  class Checker
    include Singleton

    attr_reader :dictionary

    def initialize
      @dictionary = Hash.new(1)
      load
    end

    def exists?(word)
      dictionary.has_key? word
    end

    private

    def dictionary_path
      File.expand_path(File.dirname(__FILE__) + '/dictionary')
    end

    def load
      File.open(dictionary_path) do |io|
        io.each { |line| line.chomp!; @dictionary[line] = line }
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
LittleWeasel-0.0.3 lib/LittleWeasel.rb
LittleWeasel-0.0.2 lib/LittleWeasel.rb