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
- Host: GitHub
- URL: https://github.com/rmosolgo/mruby-examples
- Owner: rmosolgo
- Created: 2014-11-12T05:24:02.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T03:57:49.000Z (almost 3 years ago)
- Last Synced: 2025-10-30T00:42:09.714Z (2 months ago)
- Language: C
- Size: 6.84 KB
- Stars: 9
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
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
```