OMG! Kitties! Ruby Syntax Extension

This is library for extending the Ruby programming language syntax. It allows for more dynamic control over program flow, with particular emphasis on conditions that will cause the program to halt execution. See the project README file for more details.

Wait, What?


OK, so it’s not really a syntax extension, though that would be one way to get this functionality. Instead of mucking about with the Ruby parsing engine, I have added a class and a couple of methods to the ‘Kernel` module. The new class is called `Kitties`; the new methods are `kitties!`, which returns a new instance of `Kitties`, and `omg!`, which accepts a single argument and decides its behavior based on that argument’s class. Currently, if that class is ‘Kitties`, `omg!` calls the system `exit` method; for anything else it just returns `nil`. The real innovation here is that you can now exit your Ruby scripts by typing

omg! kitties!

Shirley You’re Joking!


I’m quite serious, and my apologies to you if you were looking for more functionality. Frankly, I think it’s funny. My apologies also to chalain and Vornicus, who thought of this first but didn’t seem to see the true importance of bringing this technique to the Ruby-world-at-large.

Installation


The easiest way to install this software is via [RubyGems](www.rubygems.org/ “The RubyGems Project”).

  1. Download the ‘omg_kitties` source code from the [RubyForge

Project](rubyforge.org/projects/omgkitties/ “RubyForge: OMG! Kitties!”)

  1. From the shell, change to the project directory and run ‘rake` to build the

gem file

  1. Run something like ‘sudo gem install pkg/omg_kitties-VERSION.pkg` to install

the gem. Replace ‘VERSION` with the appropriate version number (duh).

  1. Profit! Wait, no.

Usage


‘omg! kitties!` is pretty much as simple as its name implies.

require ‘rubygems’ require ‘omg/kitties’ # … some truly righteous code … # I want to exit the script here omg! kitties! puts ‘This statement will never be executed!’

What’s Next?


In theory, ‘omg! kitties!` could be expanded into some kind of actually useful error-catching mechanism. Perhaps as a kind of alias for `rescue`, where maybe you encounter `kitties!` but maybe you encounter a `lolrus?` who’s just looking for his bucket, and in that case you don’t want to exit the script, you just want to print something silly to the user’s console. Who knows. It’s highly unlikely that this code will ever be expanded, though.

Who are You?


My name is Cody Brimhall. I recently graduated from UC Davis with a degree in linguistics, and currently I work for the very same University doing web programming in general, and [iTunes U](deimos3.apple.com/indigo/main/main.xml “Launch iTunes and visit iTunes U in the Music Store”). Ruby and I have been pretty serious for over a year now, and we’re thinking of moving in together and taking our relationship to the next level. Don’t tell Ruby, but my first and only real love is for Objective-C and [Apple’s Cocoa frameworks](developer.apple.com/cocoa/ “The Cocoa Frameworks”). [I also have a dumb blog](somuchwit.com/blog/ “So Much Wit: Not Really Worth Your Time”).

If you wanted to email me for some reason, I’m not that hard to find: <[email protected]>.