Module: Namazing

Defined in:
lib/namazing.rb,
lib/namazing/wordup.rb,
lib/namazing/namazing.rb

Defined Under Namespace

Classes: Wordup

Constant Summary collapse

WORDLIST =
File.open(File.expand_path("../word_list_filtered.txt", __FILE__)).readlines.collect { |l| l.chomp! }
WORDLIST_SIZE =
WORDLIST.size

Class Method Summary collapse

Class Method Details

.convert(boring_word) ⇒ Object



26
27
28
29
30
# File 'lib/namazing/namazing.rb', line 26

def self.convert boring_word
  digest = Digest::SHA256.hexdigest boring_word.downcase
  wordlist_line = (WORDLIST.size * digest[0..9].hex.to_f / ("F" * 10).hex).to_i
  WORDLIST[wordlist_line]
end

.random ⇒ Object



13
14
15
16
# File 'lib/namazing/namazing.rb', line 13

def self.random
  random_line_number = 1 + rand(WORDLIST_SIZE - 1)
  WORDLIST[random_line_number]
end

.to_awesome(boring) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/namazing/namazing.rb', line 18

def self.to_awesome boring
  wordup = Wordup.new boring
  wordup.split.each do |word|
    wordup.awesomes << Namazing.convert(word)
  end
  wordup.awesome
end

.version ⇒ Object



9
10
11
# File 'lib/namazing/namazing.rb', line 9

def self.version
  "0.0.2"
end