Questions tagged [opalrb]

Opal is a Ruby to JavaScript source-to-source compiler. It comes packed with the Ruby corelib you know and love. It is both fast as a runtime and small in its footprint.

Opal is a Ruby to JavaScript compiler. It is source-to-source, making it fast as a runtime. Opal includes a compiler (which can be run in any browser), a corelib and runtime implementation. The corelib/runtime is also very small.

Opal is hosted on github, discussed on Gitter, has a Freenode IRC channel at #opal and is on twitter @opalrb.

More documentation can be found in the docs.

92 questions
22
votes
4 answers

How can I compile Ruby to Javascript?

I'm working on a piece of logic that I would like to express on the server as well as in the browser. Something like validating a form where there must be certain logical relationships between the elements based on what has already been…
raganwald
  • 2,695
  • 1
  • 16
  • 8
13
votes
4 answers

Converting Ruby 1.9.2 code to JavaScript?

Is it possible to convert Ruby code to Javascript at all? I have heard of RubyJS but this appears to not work with Ruby 1.9.2 - is this the case?
AndyNico
  • 863
  • 4
  • 11
  • 17
13
votes
1 answer

What are the limitations of Opal?

I'm very keen to try Opal in a new Rails project, but the risk of course is that I won't discover what it can't do until I've spent hundreds of hours doing everything else, and run into a brick wall that I can't possibly get through. What are its…
iconoclast
  • 21,213
  • 15
  • 102
  • 138
9
votes
1 answer

Get the error line in a Ruby Opal code

class Test def initialize end def crash print x end end Test.new.crash Clearly this snippet will crash at line 8. If you parse this with Opal, you will get this compiled code: /* Generated by Opal 0.8.0.beta1 */ (function(Opal) { …
Saturn
  • 17,888
  • 49
  • 145
  • 271
7
votes
2 answers

Can I use Ruby gems in Opal?

There's opal-irb and opal-jquery and vienna but is there any way to use gems directly in the browser via Opal?
themirror
  • 9,963
  • 7
  • 46
  • 79
6
votes
1 answer

Converting Javascript datatables to use Opal in Rails app

I am using the ajax-datatables-rails. Below is the JS for my datatable. I want to convert the javascript into equivalent Opal.rb. jQuery(document).ready(function() { var table = $('#organizations-datatable'); var token =…
Michael K Madison
  • 2,242
  • 3
  • 21
  • 35
6
votes
4 answers

Programming Unity Games with Ruby

So I see that unity has the support for c#, JS and Boo. I could learn one of these but I would like to make a 'compiler' or something similar that would let me write ruby code and either output JS code or make a layer that could be read by the Unity…
joncodo
  • 2,298
  • 6
  • 38
  • 74
5
votes
1 answer

How to call native javascript methods from opal?

I'm coding a simple game based on html canvas. I'm now porting from coffeescript to opal. I'd like to wrap the CanvasRenderingContext2D object in an efficient way. My current solution is a wrapper, but I'd really like to make that toll free…
edx
  • 1,317
  • 1
  • 12
  • 14
5
votes
3 answers

OpalRb with MeteorJS?

I have been intrigued by the power and elegance that Opal offers in the way of using pure Ruby vs CoffeeScript or, of course, JS. How would one go about leveraging Opal for Meteor as the primary language for development? UPDATE: just wanted to…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
4
votes
1 answer

Getting error text on the client when a model does not save

I am using the Hyperstack.org framework, so working with Opal compiled Ruby code. Hyperstack's integration with Rails creates a representation of some of the Models on the client and I have a question about error validation in the response. When…
BarrieH
  • 373
  • 3
  • 11
4
votes
1 answer

Use start? method from opal-browser

I am trying to translate this js code into ruby code document.ontouchstart ? 'touchstart' : 'click'; I am using opal-browser to get browser functionality. My current attempt is this: touch = Browser::Event::Touch.new puts touch.start? However this…
4
votes
1 answer

How do I use jquery's .html( ) in opal-jquery?

I've read all of the documentation I can find and it is a bit spotty. Can someone tell me how to use jquery's .html() method in the ruby -> jquery bridge opal-jquery? Also any advice for how I would go about figuring out implemented methods in a…
3
votes
0 answers

Embed a ruby gosu game to play in a browser

I have played with some gosu tutorials to create a simple gosu game using my mac. I followed the instructions in https://www.libgosu.org/ruby.html My question is: Can a gosu game be set up to run on a website using something like…
Laurie
  • 162
  • 1
  • 11
3
votes
2 answers

OpalRB: Using functions as parameters

I'm using Opal in my MeteorJS project. I'm trying to figure out a way to do the Meteor.startup code, but it doesn't seem to work.. I thought this would work: require 'native' @Meteor = `Meteor` @Meteor.startup do puts 'Go' end But it doesn't.…
Tim Baas
  • 6,035
  • 5
  • 45
  • 72
3
votes
3 answers

uninitialized constant Object::Element in Opal RB

Trying my hand at Opal/JQuery. My app.rb file looks like this: require 'opal' require 'opal-jquery' class HTMLObject def initialize end def write_to_body end end class HTMLParagraph < HTMLObject attr_accessor :inner_html def…
RedMage
  • 1,126
  • 1
  • 9
  • 21
1
2 3 4 5 6 7