I have following code.
class Person def eat puts "I am eating" end def sleep puts "I am going to bed" end def laugh puts "Wahahaha" end def talk puts "...." end end little_boy = Person.new puts 'Input an action' request = gets.chomp if request == 'eat' little_boy.eat elsif request == 'sleep' little_boy.sleep elsif request == 'laugh' little_boy.laugh elsif request == 'talk' little_boy.talk else puts 'Input error' end
Now I would like to use method: respond_to? and send to simplify it.How
would it be?