Skip to main content

Ruby (Wasm)

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

LiveCodes uses ruby.wasm to run Ruby in the browser.

ruby.wasm is a collection of WebAssembly ports of the CRuby. It enables running Ruby application on browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms.

ruby.github.io/ruby.wasm/

Note

LiveCodes also supports running Ruby using Opal which is a Ruby to JavaScript source-to-source compiler. Read documentation here.

Usage

LiveCodes runs Ruby in the browser, including the stdlib.

JavaScript interoperability and DOM access is achieved using "JS" module. See the starter template for an example.

Language Info

Name

ruby-wasm

Extension

.wasm.rb

Alias

rubywasm

Editor

script

Compiler

ruby.wasm

Version

ruby.wasm v2.6.2, running Ruby v3.3

Code Formatting

Not supported for Ruby.

Example Usage

show code
import { createPlayground } from 'livecodes';

const options = {
"params": {
"ruby-wasm": "class User\n attr_accessor :name\n\n def initialize(name)\n @name = name\n end\n\n def admin?\n @name == 'Admin'\n end\nend\n\nuser = User.new('Bob')\n\n# the output will go to the console\nputs user\nputs user.admin?\n",
"console": "full"
}
};
createPlayground('#container', options);

This example demonstrates stdlib usage, JavaScript interoperability and DOM access:

show code
import { createPlayground } from 'livecodes';

const options = {
"template": "ruby-wasm"
};
createPlayground('#container', options);

Starter Template

https://livecodes.io/?template=ruby-wasm