Skip to content

chadowo/mruby-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MRuby Examples

C

Collection of sample MRuby programs.

Build

Get MRuby

Make sure you've got MRuby installed, see here.

Tip

If you are on Linux chances are MRuby is already in the package repositories of your favorite distro! then you'll need to use your distro specific package manager to install it. E.g:

APT:

sudo apt install libmruby-dev

DNF:

sudo dnf install mruby-devel

Pacman:

sudo pacman -S mruby

Other requirements

Some examples require SDL2. Install it:

$ sudo apt install libsdl2-dev

or

$ sudo dnf install SDL2-devel

Compiling

Use the followings commands:

cmake -S . -B build
cmake --build build

Summary

Examples included here:

Basic

Example Description
hello-world Classic hello world.
hello-file Load and execute Ruby code from a file.
pushing-variables Define various types of variables from C to Ruby.
objects Create classes & objects from C.
method-defined Check if a certain method is defined on Ruby.
call-methods Call Ruby methods from C.
using-cdata Wrap C data inside a Ruby object.
kwargs Parse keyword arguments.
blocks Interact with Ruby's block from C.
compiling-bytecode Compile Ruby code into bytecode format and save it on the disk.

SDL2

Example Description
sdl-wrapper Basic wrapper around SDL2 to create a window.

Credits

Credits where due, here are some helpful articles/post/resources that helped me to learn how to use MRuby:

License

All the examples found here are licensed under the MIT License.

About

Collection of sample MRuby programs

Topics

Resources

License

Stars

Watchers

Forks