Ruby: Invented in Japan and clearly designed for programming the controls for Gundams.

Random Ruby Notes

April 1st, 2010
Tags: ,

Installation in CentOS:

Set up access to the Extra Packages for Enterprise Linux repository. Install ruby, ruby-mysql (you know you want to), rubygems. Generically, you can then gem install whatever else you might need.

Variable tests in s/printf are deliciously C-like:

printf "%s %d\n", vslist[i], enabled[i] == false ? 0 : 1

Escaping double quotes in s/printf is exactly what you’d expect:

printf "\"%s\", %d\n", vslist[i], enabled[i] == false ? 0 : 1

Including Local Files Via require:

This is where Ruby falls down, to be sure. In order to do this, you need to modify the path of require or some such. At any rate, this does it:

$: << File.dirname(__FILE__) + "/wsdl/" unless $:.include? File.dirname(__FILE__) + "/wsdl/"

Basically, this gets placed before the require statement for your local .rb file. In this situation, it's allowing me to access files in a directory titled 'wsdl' that rests under the directory that the Ruby script I'm calling is in. I believe that, if you have the files you're require'ing in the same directory, you should just be able to get rid of the + "/wsdl/" segment in the above statement. I'd like to think there's an easier way to do this, but this at least works, even if it is quick and dirty.