Just move the method definition to beforer you call it (i.e. above puts time_keeper.display_bad_action) charlie bowman wrote: > Here is a simplified version of a little timekeeper app that I've been > using to learn ruby with. The TimeKeeper class is a class I created > also. I want to add a method to the script that displays some text if a > bad action occurs but I can't get it to work. I don't know how to tell > the script to use the method ( or function as I would call it in perl). > This is my error. > > undefined method `display_bad_action' for #<TimeKeeper:0xb7fc8730> > (NoMethodError > > usr/bin/ruby > > require 'TimeKeeper' > > ## create the TimeKeeper object > time_keeper = TimeKeeper.new(ARGV) > puts time_keeper.display_bad_action(time_keeper.action) > > ## method to display messages regarding bad action (ie can't logout when > on break) > def time_keeper.display_bad_action(action) > case action > when 'break' > return 'You are currently clocked in. Your options are: out or > break' > else > return @status > return "I don\'t recognize your last action (#{@status}) recorded > action. Please fix it in the log." > end > end > > > -- > Posted via http://www.ruby-forum.com/.