This is the first in a series of entries which I’m pulling over
articles from an old blog, revising, etc… The Problem One of the
neat things about Ruby is it’s ability to create accessor methods
for you, by simply declaring attr_reader, attr_writer, or
attr_accessor. However, there’s not an easy way to define a
default [...]
Date Published: Sep 01, 2009 - 1:42 pm
Command line arguments can be a hassle to parse. Trollop makes them
easier.
Date Published: Aug 21, 2009 - 9:11 am
On a particular, nameless, heterogenous project using ruby on
rails, ant, and shell scripts, there was an instance where data was
not being properly cleaned before going into the database
(primarily due to user errors in property files which were used by
ant to feed the database). As a result, the database
was filled with [...]
Date Published: Aug 20, 2009 - 10:27 am
One of the features of Ruby’s Kernel module (which is imported into
Object, so it’s available in every class) is the binding. The
binding allows you to keep a pointer to the scope at a particular
location in your application and then later evaluate code from that
location. For example (and this came up as [...]
Date Published: Aug 19, 2009 - 3:06 pm
#method_missing is a useful feature in ruby. However, there's
something that many people miss when using it.
Date Published: Aug 18, 2009 - 12:57 pm
The hiatus has been due to me having been really sick with a weird
neurological disorder. I didn’t do any coding at all for over
2 months. I’m starting to feel better, but I still have my
good days and bad. So, there will be updates. Hopefully
before not too much longer.
Date Published: Apr 10, 2009 - 11:26 am
Image via Wikipedia One of the neat things about ruby is that, in
general, operators are methods, so they can be overridden. When
working with multidimensional arrays, some languages allow you to
do the following: a[0,0] whereas ruby uses: a[0][0] Which makes
sense, since Ruby implements it as an array of arrays and you’re
chaining [...]
Date Published: Feb 23, 2009 - 2:53 pm
To paren, or not to paren: that is the question: Whether ’tis
nobler in the mind to suffer The bugs and errors of maintenance
programs, Or to take arms against a host of typos, And by debugging
end them? To hack: to slash; No more; and by a slash to say we end
The heart-ache [...]
Date Published: Feb 20, 2009 - 12:11 pm
In irbrc goodness, I touched briefly on my_methods, a method of
discovering the methods of an object which are distinct from those
inherited from Object. The method looks like this: class Object def
my_methods (self.methods - Object.methods).sort end end I have
since had the idea of extending it — now you can also choose to
[...]
Date Published: Feb 19, 2009 - 4:00 am
Here’s my (current) .irbrc, with comments # I am including gems in
my irb session. Therefore, the next require require 'rubygems' #
wirble is a wonderful gem which add nice features to irb require
'wirble' # Dr. Nic's useful helper gem. It makes it so you can say:
# foo.map_by_bar # instead of having to [...]
Date Published: Feb 18, 2009 - 3:26 pm