diff --git a/Building-your-Ruby-environment-and-accessing-it..md b/Building-your-Ruby-environment-and-accessing-it..md index a8d7936..5933e2c 100644 --- a/Building-your-Ruby-environment-and-accessing-it..md +++ b/Building-your-Ruby-environment-and-accessing-it..md @@ -8,7 +8,7 @@ Lets first define some class in Ruby code, and try to access this from C: Create a file `wiki-example.rb` with the following content. This class is already prepared for the next section (manipulating Ruby classes from C). We now only need the 'get_version' method. -````` +`````ruby module WikiExample class WikiManager attr_accessor :active @@ -28,7 +28,7 @@ end Then we write a C stub and small program to access this code. We first initialize mruby, then load the code file and the third step is to access the module, class and instance method. Name the file `wiki-example.c`. -````` +`````c #include "mruby.h" #include "mruby/irep.h" @@ -78,7 +78,7 @@ The strategy is first to update the existing class. Here we add a C-method to th To add a method to a class, we first need a reference to the class. We can copy the lines from the first example for getting a reference to the class WikiManager, of just insert the next lines just before the `If crashed...` comment line. -````` +`````c // add the method to the WikiManager class mrb_define_method(mrb, class, "_we_connected", we_connected, MRB_ARGS_NONE()); @@ -88,7 +88,7 @@ To add a method to a class, we first need a reference to the class. We can copy Then we add the following method between the `#include` and `int main` lines: -````` +`````c mrb_value we_connected(mrb_state* mrb, mrb_value self){ // we need an int from the args