This example shows you how to encapsulate a simple C library to use it inside a Ruby Module. This approach uses mkmf.rb that helps to create a Makefile that will correctly compile and link the C extension to ruby and a third-party library. The ruby.h header is included in the my_ruby_ext.c
file that helps to encapsulate the existing library to use it in Ruby after compiling it.
Install dependencies and compile the C library:
bin/setup
Start an irb console with the library loaded
$ bin/console
# calling the hello method
MyRubyExt.hello('JuanCrg90')
# Calling the square method
MyRubyExt.square(5)
Bug reports and pull requests are welcome!