Sha256: bdf7c21ccf248dc7a7d85921dcdb79a46eb760bddfb254da0e10ab96df1d8956
Contents?: true
Size: 771 Bytes
Versions: 1
Compression:
Stored size: 771 Bytes
Contents
module GuessWhoNoFuzzy module NamesLoader def self.load! names_by_first_letter = {} filenames = [ "files/initials.txt", "files/females.txt", "files/males.txt", "files/surnames.txt" ] filenames.each do |filename| path = File.join(File.dirname(__FILE__), '../../', filename) f = File.open(path, "r") f.each_line do |l| name = l.split(" ")[0] first_char = name[0] names_by_first_letter[first_char] ||= [] names_by_first_letter[first_char] << name end f.close end @@names_by_first_letter = names_by_first_letter end def self.names_by_first_letter(letter); @@names_by_first_letter[letter] || []; end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guess_who_no_fuzzy-0.2.0 | lib/guess_who_no_fuzzy/names_loader.rb |