Last active
August 29, 2015 14:18
-
-
Save max-power/b6f9af84da9aed1974ba to your computer and use it in GitHub Desktop.
ruby port of https://github.com/githubert/schmutz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Schmutz | |
Types = { | |
feinstaub: ["\u0323", "\u0307", "\u0312"], | |
mettwurst: ["\u0314", "\u031C", "\u0358", "\u0353", "\u0335"], | |
nein_nein: ["\u0337", "\u0338", "\u0336", "\u0335", "\u20d2", "\u20d3", "\u20e5", "\u20e6", "\u20eb"] | |
}.freeze | |
Types.each do |name, runes| | |
define_singleton_method name do |input, prop = 0.25| | |
mangle(input, runes, prop) | |
end | |
end | |
def self.mangle(input, runes, prop) | |
input.each_char.with_object("") do |char, output| | |
output << char | |
output << runes.sample if (rand < prop) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schmutz.feinstaub('Hello World!') | |
Schmutz.mettwurst('Hallo Welt!', 0.75) | |
Schmutz.nein_nein('Hallo Welt!', 0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment