Timothy Goddard
1/18/2006 12:40:00 AM
I don't believe this is possible, but neither can I think why you would
need to. Please explain what you are trying to achieve as there may be
a better way to accomplish it. If you had a method called clean_swamp
you could obtain the number of arguments required with
method(:clean_swamp).arity but not the names. I'm not even sure these
parameter names are actually stored at all after the method has been
defined.
If you need to include usage instructions you could do something like:
$usage = Hash.new('No usage instructions defined.')
class Method
def usage
$usage[self.to_s]
end
def usage=(new_usage)
$usage[self.to_s] = new_usage
end
end
def clean_swamp(swamp, slime_amount)
swamp.slime -= slime_amount
end
method(:clean_swamp).usage = 'clean_swamp(swamp, slime_amount)'
puts method(:clean_swamp).usage