Class: NodeRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/version.rb,
lib/node-runner.rb

Defined Under Namespace

Classes: Executor

Constant Summary collapse

VERSION =
"1.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(source = "", options = {}) ⇒ NodeRunner

Returns a new instance of NodeRunner.



8
9
10
11
12
13
# File 'lib/node-runner.rb', line 8

def initialize(source = "", options = {})
  @source  = encode(source.strip)
  @args = options[:args] || {}
  @executor = options[:executor] || NodeRunner::Executor.new
  @function_name = options[:function_name] || "main"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/node-runner.rb', line 19

def method_missing(m, *args, &block)
  @function_name = m
  if block
    @source = encode(block.call.strip)
  end
  @args = *args
  exec
end

Instance Method Details

#outputObject



15
16
17
# File 'lib/node-runner.rb', line 15

def output
  exec
end