Minor Change Proposal for Classes ‘Object’ and ‘Method’
I would like to make a small change suggestion on the class ‘Method’ by
the method ‘Object#method’ is also affected.
When creating a ‘Method’ object, it is not possible to receive the
identification of the object which uses the ‘Object#method’ method (see
for Workaround’ for details) by using some Method of class ‘Method’.
It is useful for some applications to analyse later on which to which
method is bound in an object of class ‘Method’. In addition, it is
missing from my viewpoint, because it is an essential information
an object of class ‘Method’.
A minor wish is an additional method for class ‘Method’, which returns
contents of ‘Method#to_s’ as an Array containing two elements, the
and the method-name without the textual border of ‘Method#to_s’. It is
and less expensive to return this existing information by a method of
‘Method’, than to use a regular expression later on to extract the
The method names used by here are only suggestions, since I needed names
example. Regarding definite names I have no emotions.
Example for Workaround >>>>>
alias :_org_method :method
method_object = self._org_method(name)
method_object.instance_id = self.object_id
md = self.to_s.match(/Method:\s*([^#]+)#([^>]+)>/)
return md, md
Now an example
puts “An instance of Hugo says ‘Hi!’”
my_hugo = Hugo.new
puts my_hugo.object_id # => 22497820 (for example)
myhi = my_hugo.method(:hi)
myhi # => An instance of Hugo says ‘Hi!’
puts myhi.instance_id # => 22497820 (for example)
p myhi.method_name # => [“Hugo”, “hi”]
End of Example >>>>>
Please inform me, if this is not the right place for a change proposal.
Wolfgang Nádasi-Donner (WoNáDo)