The first thing we need to look at is how to represent and access Ruby
datatypes from within C.
Everything in Ruby is an object, and all
variables are references to objects. In C, this means that the type
of all Ruby variables is
VALUE
,
which is either a pointer to a Ruby object or an immediate value (such
as
Fixnum
).
This is how Ruby implements object-oriented code in C: a Ruby object
is an allocated structure in memory that contains a table of instance
variables and information about the class. The class itself is
another object (an allocated structure in memory) that contains a
table of the methods defined for that class. On this foundation hangs
all of Ruby.