Class: Quickjs::Runnable

Inherits:
Object
  • Object
show all
Defined in:
lib/quickjs/runnable.rb,
sig/quickjs.rbs

Instance Method Summary collapse

Constructor Details

#initialize(bytecode) ⇒ Runnable

Returns a new instance of Runnable.

Parameters:

  • bytecode (String)


5
6
7
# File 'lib/quickjs/runnable.rb', line 5

def initialize(bytecode)
  @bytecode = bytecode
end

Instance Method Details

#run(on: nil) ⇒ Object

Parameters:

  • on: (VM, Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Object)


13
14
15
# File 'lib/quickjs/runnable.rb', line 13

def run(on: nil)
  Quickjs._with_vm(on) {|vm| vm.send(:_run_bytecode, @bytecode) }
end

#to_sString

Returns:

  • (String)


9
10
11
# File 'lib/quickjs/runnable.rb', line 9

def to_s
  @bytecode
end