Sha256: 4d77fed26940f4e060fcec509f1e2f24a9044c960abf7499cb1597cd044a0f54
Contents?: true
Size: 742 Bytes
Versions: 1
Compression:
Stored size: 742 Bytes
Contents
require 'digest' require_relative 'wordup' module Namazing WORDLIST = File.open(File.expand_path('../word_list_filtered.txt', __FILE__)).readlines.collect { |l| l.chomp! } WORDLIST_SIZE = WORDLIST.size def self.version "0.0.4" end def self.random random_line_number = 1 + rand(WORDLIST_SIZE - 1) WORDLIST[random_line_number] end def self.to_awesome boring wordup = Wordup.new boring wordup.split.each do |word| wordup.awesomes << Namazing.convert(word) end wordup.awesome end 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
namazing-0.0.4 | lib/namazing/namazing.rb |