Class: Rhino::Ruby::Object

Inherits:
JS::ScriptableObject
  • Object
show all
Includes:
JS::Wrapper, Scriptable
Defined in:
lib/rhino/ruby.rb

Constant Summary collapse

TYPE =
JS::TopLevel::Builtins::Object

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scriptable

access, access=, #get, #getIds, #has, #put

Constructor Details

#initialize(object, scope) ⇒ Object

Returns a new instance of Object.



102
103
104
105
106
# File 'lib/rhino/ruby.rb', line 102

def initialize(object, scope)
  super()
  @ruby = object
  JS::ScriptRuntime.setBuiltinProtoAndParent(self, scope, TYPE) if scope
end

Class Method Details

.wrap(object, scope = nil) ⇒ Object

wrap an arbitrary (ruby) object



96
97
98
# File 'lib/rhino/ruby.rb', line 96

def self.wrap(object, scope = nil)
  Ruby.cache(object) { new(object, scope) }
end

Instance Method Details

#equivalentValues(other) ⇒ Object Also known as: ==

protected Object ScriptableObject#equivalentValues(Object value)



123
124
125
# File 'lib/rhino/ruby.rb', line 123

def equivalentValues(other) # JS == operator
  other.is_a?(Object) && unwrap.eql?(other.unwrap)
end

#getClassNameObject

abstract String Scriptable#getClassName();



114
115
116
# File 'lib/rhino/ruby.rb', line 114

def getClassName
  @ruby.class.to_s # to_s handles 'nameless' classes as well
end

#toStringObject



118
119
120
# File 'lib/rhino/ruby.rb', line 118

def toString
  "[ruby #{getClassName}]" # [object User]
end

#unwrapObject

abstract Object Wrapper#unwrap();



109
110
111
# File 'lib/rhino/ruby.rb', line 109

def unwrap
  @ruby
end