-
Execute code if a script directly called
I often want to run some arbitrary code if I run a script directly. The primary example that comes to mind these days is: Strangely enough, despite primarily using Ruby on a daily basis, I haven’t really thought about how this test looks in Ruby: Bash seemed a little more obvious, but apparently there’s a…
-
Extending Immediate Types and Source Locations in Ruby
Overridding singleton classes of instances In Ruby, most types allow you to open up their singleton classes to override instance methods: Immediate values Some objects are implemented as immediate values in Ruby, and cannot be implemented have singleton methods defined on them directly: Fixnum, true, nil, and false are implemented as immediate values. With immediate values, variables hold the…
-
Handling