[Note: parts of this message were removed to make it a legal post.]
Hi All,
def one
puts "hi"
end
Once i call one --> i can able to get a output.
QUESTION:
I have a array method_list=["one"]
How can I convert "one" to method ?
In general, you can convert a string / symbol to the method it is maning by
using the method "method"
http://ruby-doc.org/core/classes/Object.html#M000336
def one() "hi" end
def two() "hello" end
def three() "hola" end
method_names = private_methods(false).reject { |name| name.size > 5 }
method_names # => ["three", "two", "one"]
method_list = method_names.map { |name| method name }
method_list # => [#<Method: Object#three>, #<Method: Object#two>, #<Method:
Object#one>]
method_results = method_list.map { |meth| meth.call }
method_results # => ["hola", "hello", "hi"]