| Start |
|---|
| Your first extension C extensions are comprised of two general pieces:
To get started with your first extension put the following in a file named A couple of things to point out: First, the name Second, the Put the following in a file named A breakdown of the code: The name The call to Finally, the call to After having compiled the extension with the call to Fire up a console! |
| Working with C Structs In order to be able to work with C structs as Ruby objects, you need to wrap them with calls to
Here's a simple example: And the After compiling the extension: |
| Writing Inline C - RubyInLine RubyInline is a framework that lets you embed other languages inside your Ruby code. It defines the Module# inline method, which returns a builder object. You pass the builder a string containing code written in a language other than Ruby, and the builder transforms it into something that you can call from Ruby. When given C or C++ code (the two languages supported in the default RubyInline install), the builder objects writes a small extension to disk, compiles it, and loads it. You don't have to deal with the compilation yourself, but you can see the generated code and compiled extensions in the .ruby_inline subdirectory of your home directory. Embed C code right in your Ruby program:
RubyInline won't work from within irb C function |
Read Article
https://develop.horje.com/learn/1434/reference