Forum: Ruby Minor Change Proposal for Classe 'UnboundMethod'

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A131b672fdbd2a58dce12031ad78b121?d=identicon&s=25 Wolfgang Nádasi-Donner (wonado)
on 2007-01-19 18:55
(Received via mailing list)
Minor Change Proposal for Classe 'UnboundMethod'

I would like to make a small change suggestion on the class


The proposal is to add one or two additional methods for class
which return the contents of 'UnboundMethod#to_s' as an two element
Array or the
parts by two independant methods.

The method name used by here is only a suggestion, since I need a names
for the

 >>>>> Example for Workaround >>>>>
class UnboundMethod
   def method_name
     md = self.to_s.match(/Method:\s*([^#]+)#([^>]+)>/)
     return md[1], md[2]

# Now an example

class Hugo
   def hi
     puts "An instance of Hugo says 'Hi!'"

my_hugo =
myhi = my_hugo.method(:hi)
unbound1 = myhi.unbind
unbound2 = Hugo.instance_method(:hi)

p unbound1.method_name # => ["Hugo", "hi"]
p unbound2.method_name # => ["Hugo", "hi"]
 >>>>>     End of Example     >>>>>


Wolfgang Nádasi-Donner (WoNáDo)
This topic is locked and can not be replied to.