Opal.rb is a Ruby to JavaScript compiler.
This addon simply includes Opal as a Service in your Ember application.
ember install ember-cli-opal-rb
There are only really two methods exposed compileRuby
and run
Here's an example of there usage.
import Ember from 'ember';
export default Ember.Component.extend({
opal: Ember.inject.service(),
someFunc: function () {
var compiler = this.get('opal')
var textToCompile = this.get('text');
//This will give you the Ruby code as JS
var compiled = compiler.compileRuby(textToCompile);
//This will compile and execute the Ruby code
compiler.run(textToCompile);
}
});
If you clone the repo and run the server there is an example of a live Ruby to JS converter.
ember server
- Visit your app at http://localhost:4200.
ember try:testall