Class: ExecJS::ExternalRuntime

Inherits:
Object
  • Object
show all
Defined in:
lib/execjs/external_runtime.rb

Defined Under Namespace

Classes: Context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ExternalRuntime

Returns a new instance of ExternalRuntime.



90
91
92
93
94
95
96
97
98
# File 'lib/execjs/external_runtime.rb', line 90

def initialize(options)
  @name        = options[:name]
  @command     = options[:command]
  @runner_path = options[:runner_path]
  @test_args   = options[:test_args]
  @test_match  = options[:test_match]
  @encoding    = options[:encoding]
  @binary      = locate_binary
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



88
89
90
# File 'lib/execjs/external_runtime.rb', line 88

def name
  @name
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


114
115
116
117
# File 'lib/execjs/external_runtime.rb', line 114

def available?
  require "multi_json"
  @binary ? true : false
end

#compile(source) ⇒ Object



110
111
112
# File 'lib/execjs/external_runtime.rb', line 110

def compile(source)
  Context.new(self, source)
end

#eval(source) ⇒ Object



105
106
107
108
# File 'lib/execjs/external_runtime.rb', line 105

def eval(source)
  context = Context.new(self)
  context.eval(source)
end

#exec(source) ⇒ Object



100
101
102
103
# File 'lib/execjs/external_runtime.rb', line 100

def exec(source)
  context = Context.new(self)
  context.exec(source)
end