module MagicWords::Dict
Public Class Methods
from_file(name, filename)
click to toggle source
# File lib/magic_words/dict.rb, line 16 def self.from_file(name, filename) from_list(name, File.readlines(filename)) end
from_list(name, words)
click to toggle source
# File lib/magic_words/dict.rb, line 3 def self.from_list(name, words) const_set( name.upcase, Module.new do words.map(&:strip).each do |word| next unless /^[A-Za-z]*$/.match?(word) const_set(word.upcase, word.downcase) unless const_defined?(word.upcase) end end ) end