Class: ExecJS::Runtime

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

Overview

Abstract base class for runtimes

Defined Under Namespace

Classes: Context

Instance Method Summary collapse

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/execjs/runtime.rb', line 76

def available?
  raise NotImplementedError
end

#compile(source, options = {}) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/execjs/runtime.rb', line 64

def compile(source, options = {})
  if context_class.instance_method(:initialize).arity == 2
    context_class.new(self, source)
  else
    context_class.new(self, source, options)
  end
end

#context_classObject



40
41
42
# File 'lib/execjs/runtime.rb', line 40

def context_class
  self.class::Context
end

#deprecated?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/execjs/runtime.rb', line 72

def deprecated?
  false
end

#eval(source, options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/execjs/runtime.rb', line 54

def eval(source, options = {})
  context = compile("", options)

  if context.method(:eval).arity == 1
    context.eval(source)
  else
    context.eval(source, options)
  end
end

#exec(source, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/execjs/runtime.rb', line 44

def exec(source, options = {})
  context = compile("", options)

  if context.method(:exec).arity == 1
    context.exec(source)
  else
    context.exec(source, options)
  end
end

#nameObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/execjs/runtime.rb', line 36

def name
  raise NotImplementedError
end