This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class | |
def pure_virtual_function(name) | |
class_eval %{ | |
def #{name}(*args, &block) | |
raise NotImplementedError, "this function needs an implementation" | |
end | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> module Horse | |
>> def neigh | |
>> puts "neigh" | |
>> end | |
>> end | |
=> nil | |
>> class Bink | |
>> include Horse | |
>> def neigh | |
>> super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'test/unit' | |
require 'mixology' | |
# in 1.9.1 the test/unit library seems to mix in PP:ObjectMixin automatically so i added | |
# that module into the list of modules to test for when checking the inheritance chains | |
# i also didn't have dust installed (and have no idea what it is) but created a self.test method | |
# that i think may perform at least some of the function; anyway this test suite passes 100% on my setup | |
class MixologyTest < Test::Unit::TestCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* this C file, */ | |
int bink = 9; | |
assembles to this: | |
.file "love.c" | |
.globl bink | |
.data | |
.align 4 | |
.type bink, @object | |
.size bink, 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static VALUE | |
rb_yield_0(val, self, klass, flags, avalue) | |
VALUE val, self, klass; /* OK */ | |
int flags, avalue; | |
{ | |
NODE *node; | |
volatile VALUE result = Qnil; | |
volatile VALUE old_cref; | |
volatile VALUE old_wrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One of my favourite C extensions for Ruby 1.8.6 is Mixology. Mixology makes it possible to dynamically mix and unmix modules from inheritance chains and can be used to do some very interesting things. Just some of the applications utilizing this kind of functionality include _why’s mixico, the decorator pattern, and the state pattern. | |
Unfortunately Mixology has not yet been ported to 1.9.1. Nonetheless I’ve been wanting to try my hand at writing an extension for 1.9.1 and so I thought I’d give it a go myself. | |
The first thing to do when porting an extension from an earlier version of Ruby to Ruby 1.9.1 is to just try compiling it and examine the errors that result. I did the following in a shell: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One of my favourite C extensions for Ruby 1.8.6 is Mixology. Mixology makes it possible to dynamically mix and unmix | |
modules from inheritance chains and can be used to do some very interesting things. Just some of the applications | |
utilizing this kind of functionality include _why’s mixico, the decorator pattern, and the state pattern. | |
Unfortunately Mixology has not yet been ported to 1.9.1. Nonetheless I’ve been wanting to try my hand at writing an | |
extension for 1.9.1 and so I thought I’d give it a go myself. | |
The first thing to do when porting an extension from an earlier version of Ruby to Ruby 1.9.1 is to just try | |
compiling it and examine the errors that result. I did the following in a shell: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template | |
Strategy | |
Observer | |
Composite | |
Iterator | |
Command | |
Adapter | |
Proxy | |
Decorator | |
Singleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initializing nautilus-open-terminal extension | |
Initializing nautilus-share extension | |
seahorse nautilus module initialized | |
Initializing nautilus-dropbox 0.5.0 | |
** (nautilus:6182): WARNING **: Unable to add monitor: Not supported | |
Segmentation fault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 8.04.1 | |
Release: 8.04 | |
Codename: hardy |