title: ruby - how to dynamically call instance method in a module
body: <p>I'm trying to dynamically call instance methods. I found <code>send</code>, <code>call</code>, <code>eval</code> to do that. There are examples of dynamically calling class methods, but I haven't figured out how to make it work for instance methods.</p>
  
  <p>e.g.</p>
  
  <pre><code>module MyModule
    def Foo
      puts "hello"
    end
  end
  </code></pre>
  
  <p>the instance method names can be listed by:</p>
  
  <pre><code>MyModule.instance_methods
  #=&gt; [:Foo]
  </code></pre>
  
  <p>But I can't figure out how to call the method:</p>
  
  <pre><code>MyModule.send("Foo")
  #=&gt; NoMethodError: undefined method `Foo' for MyModule:Module
  
  MyModule.method("Foo").call
  #=&gt; NameError: undefined method `Foo' for class `Module'
  
  eval 'MyModule.Foo'
  #=&gt; NoMethodError: undefined method `Foo' for MyModule:Module
  </code></pre>
  
  <p>How can I call the instance methods, like <code>Foo</code>, by the method name?</p>