0

I'm taking baby steps with opalrb, here is my main.rb:

require 'native'

def main
    puts "hi from the main function in main.rb"
end

def demoButton
    outputDiv = Element.find('output').get(0)
    puts outputDiv.methods.sort
end

It's included within <head> after opal.js and ...opal-parser.js" onload="Opal.load('opal-parser')" but the console shows an exception thrown:

{
  message: "cannot load such file -- native",
​  name: "LoadError",
​  stack: ""
}

native seems to be part of the opal standard library, so why is there a problem including it?

Vasiliy Sharapov
  • 997
  • 1
  • 8
  • 27
  • Here's the demo (may be fixed when you read this): https://vsharapov.github.io/opalrb-boilerplate/main.html And the code: https://github.com/VSharapov/opalrb-boilerplate/tree/96d80b3d17df52c7ef14f7429dd87fc77a3a3ead – Vasiliy Sharapov Oct 26 '21 at 19:50

1 Answers1

0

Add this:

<script src="https://cdn.opalrb.com/opal/current/native.js"></script>

The stdlib part (like native) of Opal isn't included in opal.js. For a full list of stdlib, take a look here:

https://cdn.opalrb.com/opal/current/index.html

hmdne
  • 434
  • 2
  • 5