From: Nobuyoshi Nakada Date: 2008-09-09T07:21:50+09:00 Subject: Re: #to_self Hi, At Mon, 8 Sep 2008 00:35:34 +0900, Trans wrote in [ruby-talk:314145]: > That could work, but if to_self is used there will be issues clearly > (!!!!!!!!! ain't a number). Hence, what I'm really after is an > optional method that can be defined when needed to say "how to become > grumpy". Then: Why not just override Symbol#grumpy? module Grumpy def grumpize "#{to_s.upcase}!!!!!!!!!" end end class String include Grumpy end class Symbol include Grumpy def grumpize super.to_sym end end p "fun".grumpize #=> "FUN!!!!!!!!!" p :fun.grumpize #=> :"FUN!!!!!!!!!" Or, String#try_convert is defined in 1.9: module Grumpy def grumpize self.class.try_convert("#{to_s.upcase}!!!!!!!!!") end end class String include Grumpy end class Symbol include Grumpy def self.try_convert(s) s.to_sym end end p "fun".grumpize #=> "FUN!!!!!!!!!" p :fun.grumpize #=> :"FUN!!!!!!!!!" -- Nobu Nakada