Skip to content

Commit

Permalink
refactor: Rconv.set, Rconv.call
Browse files Browse the repository at this point in the history
  • Loading branch information
ongaeshi committed Aug 12, 2022
1 parent 7d5f172 commit 73f0236
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,25 @@ const main = async () => {
browserVm.vm.eval(
`
class Rconv
def set(opt = {}, &block)
@conv = block
def self.set(opt = {}, &block)
@conv ||= Caller.new
@conv.set(opt, &block)
end
def call(arg)
def self.call(arg)
@conv.call(arg)
end
end
$rconv = Rconv.new
class Caller
def set(opt = {}, &block)
@conv = block
end
def call(arg)
@conv.call(arg)
end
end
end
`
)

Expand All @@ -89,7 +98,7 @@ export const runRubyScriptsInHtml = function () {
// Run eval
const input2 = <HTMLTextAreaElement>document.getElementById("input2");

const result = browserVm.vm.eval(codeEditor.getValue() + `; $rconv.call("${input2.value}")`)
const result = browserVm.vm.eval(codeEditor.getValue() + `; Rconv.call("${input2.value}")`)

if (outputBuffer.length == 0) {
outputTextArea.value += result.toString() + "\n"
Expand Down

0 comments on commit 73f0236

Please sign in to comment.