Module: Transmogrifiers::Piglatin
- Defined in:
- lib/transmogrifiers/piglatin.rb
Instance Method Summary collapse
Instance Method Details
#transmogrify(name) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/transmogrifiers/piglatin.rb', line 3 def transmogrify(name) name = super.to_s append_string = '' if match = name.match(/\d+$/) name, append_string = match.pre_match, match[0] end if match = name.match(/^[^aeiou]+/i) name = match.post_match + match[0] else name << 'w' end name.downcase!.capitalize! if name.match(/[A-Z]/) :"#{name}ay#{append_string}" end |