@ruby/wasm-wasi
    Preparing search index...

    Class RbValue

    A RbValue is an object that represents a value in Ruby

    Index

    Methods

    • Call a given method with given arguments

      Parameters

      • callee: string

        name of the Ruby method to call

      • ...args: RbValue[]

        arguments to pass to the method. Must be an array of RbValue

      Returns RbValue

      The result of the method call as a new RbValue.

      const ary = vm.eval("[1, 2, 3]");
      ary.call("push", 4);
      console.log(ary.call("sample").toString());
    • Call a given method that may call JS::Object#await with given arguments

      Parameters

      • callee: string

        name of the Ruby method to call

      • ...args: RbValue[]

        arguments to pass to the method. Must be an array of RbValue

      Returns Promise<RbValue>

      A Promise that resolves to the result of the method call as a new RbValue.

      const client = vm.eval(`
      require 'js'
      class HttpClient
      def get(url)
      JS.global.fetch(url).await
      end
      end
      HttpClient.new
      `);
      const response = await client.callAsync("get", vm.eval(`"https://example.com"`));