Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chadowo/mruby-examples
Collection of MRuby sample programs
https://github.com/chadowo/mruby-examples
c example-code examples mruby ruby sample-code samples
Last synced: about 1 month ago
JSON representation
Collection of MRuby sample programs
- Host: GitHub
- URL: https://github.com/chadowo/mruby-examples
- Owner: Chadowo
- License: mit
- Created: 2023-08-12T20:58:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-03T16:01:06.000Z (about 2 months ago)
- Last Synced: 2024-11-03T16:27:16.353Z (about 2 months ago)
- Topics: c, example-code, examples, mruby, ruby, sample-code, samples
- Language: C
- Homepage:
- Size: 76.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MRuby Examples
Collection of [MRuby](https://mruby.org/) sample programs.
## Build
### Get MRuby
Make sure you've got MRuby installed, see [here](https://github.com/mruby/mruby#how-to-get-mruby).
> [!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:
```console
sudo apt install libmruby-dev
```DNF:
```console
sudo dnf install mruby-devel
```Pacman:
```console
sudo pacman -S mruby
```### Compiling
Use the followings commands
```console
cmake -S . -B build
cmake --build build
```## Summary
Examples included here:
| Example | Description |
|:---------------------------------------------:| --------------------------------------------------------------- |
| [hello-world](src/hello-world/) | Classic hello world. |
| [hello-file](src/hello-file/) | Load and execute Ruby code from a file. |
| [pushing-variables](src/pushing-variables/) | Define various types of variables from C to Ruby. |
| [objects](src/objects/) | Create classes & objects from C. |
| [method-defined](src/method-defined/) | Check if a certain method is defined on Ruby. |
| [call-methods](src/call-methods/) | Call Ruby methods from C. |
| [using-cdata](src/using-cdata/) | Wrap C data inside a Ruby object. |
| [kwargs](src/kwargs/) | Parse keyword arguments. |
| [blocks](src/blocks/) | Interact with Ruby's block from C. |
| [compiling-bytecode](src/compiling-bytecode/) | Compile Ruby code into bytecode format and save it on the disk. |## Credits
Credits where due, here are some helpful articles/post/resources that helped
me to learn how to use MRuby:- [Executing Ruby code with MRuby](https://mruby.org/docs/articles/executing-ruby-code-with-mruby.html)
- [MRuby GUI series](https://dev.to/roryo/a-new-smalltalk-style-environment-for-ruby-5f5c)## License
All the examples found here are licensed under the [MIT license](/LICENSE).