class Nashorn::Ruby::Constructor

Public Class Methods

new(klass) click to toggle source
Calls superclass method Nashorn::Ruby::Function::new
# File lib/nashorn/ruby.rb, line 315
def initialize(klass)
  super(klass.method(:new))
  @klass = klass
end
wrap(klass) click to toggle source

wrap a ruby class as as constructor function

# File lib/nashorn/ruby.rb, line 309
def self.wrap(klass)
  # NOTE: caching here seems redundant since we implemented JS::Wrapper
  # and a ruby class objects seems always the same ref under JRuby ...
  Ruby.cache(klass) { new(klass) }
end

Public Instance Methods

getClassName() click to toggle source

@override ECMA [[Class]] property

# File lib/nashorn/ruby.rb, line 323
def getClassName; @klass.name end
isArray() click to toggle source

@override

# File lib/nashorn/ruby.rb, line 333
def isArray; false end
isFunction() click to toggle source

@override

# File lib/nashorn/ruby.rb, line 336
def isFunction; true end
isInstance(instance) click to toggle source

@override

# 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() click to toggle source

@override

# File lib/nashorn/ruby.rb, line 339
def isStrictFunction; false end
newObject(args) click to toggle source

@override

# File lib/nashorn/ruby.rb, line 342
def newObject(args); @klass.new(*args) end
unwrap() click to toggle source
# File lib/nashorn/ruby.rb, line 320
def unwrap; @klass end