ruby metaprogramming - getting method names and parameter info for a class -
i want class methods in object. please see following example have class "user.rb"
class user def say_name end def walk(p1) end def run(p1, p2) end end
and wrote following code
require 'user.rb' = user.new arr = a.public_methods(all = false)
above code return method name, question want method name parameters
def def run(p1, p2) end
i want method name ("run") , parameter names (p1, p2) or parameter count (2)
can me, in advance
cheers
sameera
user.new.method(:run).arity # => 2
Comments
Post a Comment