Chris Bailey wrote:
>  I'm trying to come up with an efficient way of using user input as a
> way of calling methods. I'm unhappy with the way that I am doing it
> because it isn't very flexible. This is what I'm doing now.
> 
> input = gets.downcase.chomp
> 
> if input == foo
>     do_foo()
> elsif input == bar
>     do_bar()
> else
>     puts "That isn't a command!"
> end

ALLOWED=[:foo,:bar]
input=gets.downcase.chomp.to_sym
if ALLOWED.include? input
  send(input)
else
  puts "That isn't a command!"
end

The method send calls a method specified as the first argument to send. 
Try send(:puts,"abc") as an example.

TPR.
-- 
Posted via http://www.ruby-forum.com/.