Skip to content

Instantly share code, notes, and snippets.

@max-power
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-power/b6f9af84da9aed1974ba to your computer and use it in GitHub Desktop.
Save max-power/b6f9af84da9aed1974ba to your computer and use it in GitHub Desktop.
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
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