Sha256: 1fa8792325be1a83d7ce5b5537fc6bbce8c943e015295c5eacb138617322435b
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
module Love module ThankWords class << self def title_thanks find_words('title_thanks') end def begin_author find_words('begin_author') end def middle_author find_words('middle_author') end def end_author find_words('end_author') end def person_perfix find_words('person_prefix') end def library_prefix find_words('library_prefix') end def libraries_prefix find_words('libraries_prefix') end def hearts '<3' * rand(10) end private def find_words(area) fill_thank_words unless defined?(@thank_words) cache_words rand_words_from(area), area end def fill_thank_words @thank_words = \ YAML.load(File.read(Love.root.join "../thank_words/#{Love.lang}.yml")) end def cache_words(words, area) @previous ||= {} @previous[area] ||= [] if @previous[area].count == @thank_words[area].count @previous[area] = [] end if @previous[area].include? words find_words(area) else @previous[area] << words words end end def rand_words_from(area) @thank_words[area].to_a[rand(@thank_words[area].length)] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
share_some_love-0.1.4 | lib/love/thank_words.rb |
share_some_love-0.1.3 | lib/love/thank_words.rb |