title: Calling different method depending upon variable's value without having an if-else block in Ruby
body: <p>I have a variable <code>name</code> which can have one of the three different values: <code>"name1"</code> or <code>"name2"</code> or <code>"name3"</code>. Depending upon different value, I have to call a different value. For <code>"name1"</code>, I need to call <code>method_name1</code>,for <code>"name2"</code>, I need to call <code>method_name2</code> and similarly for <code>"name3"</code>, I need to call <code>method_name3</code>.</p>
  
  <p>Currently, I do it like this: </p>
  
  <pre><code>if(name == "name1")
    output = method_name1(name)
  elsif(name == "name2")
    output = method_name2(name)
  elsif(name == "name3")
    output = method_name3(name)
  end
  </code></pre>
  
  <p>Instead of having if-elses, how can I have a map of methods to apply? How to do it in Ruby?</p>