Class: Rhino::Function

Inherits:
J::BaseFunction
  • Object
show all
Defined in:
lib/rhino/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(callable = nil, &block) ⇒ Function

Returns a new instance of Function.



55
56
57
58
# File 'lib/rhino/context.rb', line 55

def initialize(callable = nil, &block)
  super()
  @block = callable || block
end

Instance Method Details

#call(cxt, scope, this, args) ⇒ Object



60
61
62
# File 'lib/rhino/context.rb', line 60

def call(cxt, scope, this, args)
  @block.call(*(args.map {|a| To.ruby(a)}))
end

#to_json(*args) ⇒ Object



64
65
66
# File 'lib/rhino/context.rb', line 64

def to_json(*args)
  '"[Native Function]"'
end