I made some examples as I was trying out mruby. Each one has a make task, then you can run the little program.
$ make setup
It should:
- update the
mruby
submodule cd mruby
andmake
to build mruby
Run Ruby code from a string inside a C application.
$ make hello_world
$ build/hello_world
Compile Ruby code to mruby (RiteVM) bytecode, then run it with mruby.
$ make hello_bytecode
$ mruby/bin/mruby -b build/hello_bytecode.mrb
Compile Ruby to bytecode, then execute that bytecode inside a C application.
$ make hello_c_code
$ build/hello_c_code
Build a Ruby class in C, then use that Ruby class in your Ruby code.
$ make hello_classes
$ build/hello_classes
Pretend you were accessing some hardware-ish thing by C API.
fake_led.c
is my pretend LEDs. Wrap it in a Ruby class, then use that in Ruby code. The Ruby code is executed inside the C application.
$ make hello_embedded
$ build/hello_embedded