Class: Nashorn::Ruby::Constructor
- Inherits:
-
Function
- Object
- JS::AbstractJSObject
- Function
- Nashorn::Ruby::Constructor
show all
- Defined in:
- lib/nashorn/ruby.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Function
#==, #arity, #call, #equals, #getDefaultValue, #isInstanceOf, #length
Methods included from Scriptable
#getMember, #getSlot, #hasMember, #hasSlot, #keySet, #removeMember, #setMember, #setSlot
Constructor Details
Returns a new instance of Constructor.
315
316
317
318
|
# File 'lib/nashorn/ruby.rb', line 315
def initialize(klass)
super(klass.method(:new))
@klass = klass
end
|
Class Method Details
.wrap(klass) ⇒ Object
wrap a ruby class as as constructor function
309
310
311
312
313
|
# File 'lib/nashorn/ruby.rb', line 309
def self.wrap(klass)
Ruby.cache(klass) { new(klass) }
end
|
Instance Method Details
#getClassName ⇒ Object
323
|
# File 'lib/nashorn/ruby.rb', line 323
def getClassName; @klass.name end
|
333
|
# File 'lib/nashorn/ruby.rb', line 333
def isArray; false end
|
#isFunction ⇒ Object
336
|
# File 'lib/nashorn/ruby.rb', line 336
def isFunction; true end
|
#isInstance(instance) ⇒ Object
326
327
328
329
330
|
# File 'lib/nashorn/ruby.rb', line 326
def isInstance(instance)
return false unless instance
return true if instance.is_a?(@klass)
instance.is_a?(Object) && instance.unwrap.is_a?(@klass)
end
|
#isStrictFunction ⇒ Object
339
|
# File 'lib/nashorn/ruby.rb', line 339
def isStrictFunction; false end
|
#newObject(args) ⇒ Object
342
|
# File 'lib/nashorn/ruby.rb', line 342
def newObject(args); @klass.new(*args) end
|
320
|
# File 'lib/nashorn/ruby.rb', line 320
def unwrap; @klass end
|