An open API service indexing awesome lists of open source software.

https://github.com/rmosolgo/mruby-examples

Just a guy tryna learn mruby
https://github.com/rmosolgo/mruby-examples

Last synced: 2 months ago
JSON representation

Just a guy tryna learn mruby

Awesome Lists containing this project

README

          

# mruby Examples

I made some examples as I was trying out [mruby](http://github.com/mruby/mruby). Each one has a make task, then you can run the little program.

## Setup

```
$ make setup
```

It should:

- update the `mruby` submodule
- `cd mruby` and `make` to build mruby

## Hello World

Run Ruby code from a string inside a C application.

```
$ make hello_world
$ build/hello_world
```

## Hello Bytecode

Compile Ruby code to mruby (RiteVM) bytecode, then run it with mruby.

```
$ make hello_bytecode
$ mruby/bin/mruby -b build/hello_bytecode.mrb
```

## Hello C Code

Compile Ruby to bytecode, then execute that bytecode inside a C application.

```
$ make hello_c_code
$ build/hello_c_code
```

## Hello Classes

Build a Ruby class in C, then use that Ruby class in your Ruby code.

```
$ make hello_classes
$ build/hello_classes
```

## Hello Embedded

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
```