I'm new to Ruby and I would like to find out what the best way of doing things is.
Assume the following scenario:
I have a text field where the user can input strings. Based on what the user inputs (after validation) I would like to access different fields of an instance variable.
Example: @zoo is an instance variable. The user inputs "monkey" and I would like to access @zoo.monkey. How can I do that in Ruby?
One idea that crossed my mind is to have a hash:
zoo_hash = { "monkey" => @zoo.monkey, ... }
but I was wondering if there is a better way to do this?
Thanks!