Posts Tagged ‘ruby’

(Little) Console Task Manager

January 22, 2009 Leave a comment

My first ruby application. Simple console task manager with persistency. Nothing special dont be too harsh on my bad coding skills please 😛

This version has one bug, the application is fully functional but has a small bug ill get around to fixing

Code can be found here

Categories: ruby Tags: ,

Kill Messages on Ruby applications

January 9, 2009 Leave a comment

Trying to get into ruby and i ran in to a somewhat important requirement. I need to know when my app is closing, wether it was me that shut it down or the OS just simply sent it a kill message. So i did some digging, made a fool of my self by posting to comp.lang.ruby and later on found the solution. Directly from the ruby documentation:

at_exit { block } → proc

Converts block to a Proc object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration.

   def do_at_exit(str1)
     at_exit { print str1 }
   at_exit { puts "cruel world" }
   do_at_exit("goodbye ")


   goodbye cruel world

For more info visit here

Categories: ruby Tags: