Created
December 8, 2010 15:11
-
-
Save ticktricktrack/733386 to your computer and use it in GitHub Desktop.
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
# MaskedString = Class.new(String) | |
Object.const_set("MaskedString", Class.new(String)) | |
MaskedString.instance_eval do | |
define_method :tr_vowel do | |
tr 'aeiou', '*' | |
end | |
end | |
MaskedString.class_eval do | |
define_singleton_method :tr_vowel do |str| | |
str.tr 'aeiou', '*' | |
end | |
end | |
puts MaskedString.new("Rainer").tr_vowel | |
puts MaskedString.tr_vowel("Rainer") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment