From: charlie bowman Date: 2006-02-09T09:16:35+09:00 Subject: Re: how to create singleton methods in script The following code works but it's awfully ugly putting a method at the top of a script. Is this really how I have to structure a script? #!/usr/bin/ruby require 'TimeKeeper' public ## method to display messages regarding bad action (ie can't logout when on break) def display_bad_action(action) case action when 'break' return 'You are currently clocked in. Your options are: out or break' else return 5 end end ## create the TimeKeeper object time_keeper = TimeKeeper.new(ARGV) puts display_bad_action(time_keeper.action) Neowulf wrote: > You may want to try putting your method def's above the code that calls > the methods. > > This is something I fell into when I first started as well. > > ~Neowulf -- Posted via http://www.ruby-forum.com/.