class JavaScript::Object

Public Class Methods

new(proto = nil) click to toggle source
# File lib/javascript.rb, line 57
def initialize(proto = nil)
  @hash = { __proto__: proto }
end

Public Instance Methods

!=(other) click to toggle source
# File lib/javascript.rb, line 83
def !=(other)
  !(self == other)
end
==(other) click to toggle source
# File lib/javascript.rb, line 75
def ==(other)
  __method__(:==).call(other)
end
===(other) click to toggle source
# File lib/javascript.rb, line 79
def ===(other)
  self == other
end
[](key) click to toggle source
# File lib/javascript.rb, line 61
def [](key)
  if @hash.key?(key)
    @hash[key]
  elsif __proto__
    __proto__[key]
  else
    nil
  end
end
[]=(key, value) click to toggle source
# File lib/javascript.rb, line 71
def []=(key, value)
  @hash[key.to_sym] = value
end
__defined__?(key) click to toggle source
# File lib/javascript.rb, line 95
def __defined__?(key)
  @hash.key?(key) || (__proto__ && __proto__.__defined__?(key))
end
__hash__() click to toggle source
# File lib/javascript.rb, line 87
def __hash__
  @hash
end
__proto__() click to toggle source
# File lib/javascript.rb, line 91
def __proto__
  @hash[:__proto__]
end

Private Instance Methods

method_missing(name, *args, &block) click to toggle source
# File lib/javascript.rb, line 100
def method_missing(name, *args, &block)
  if name =~ /=\z/
    self[name[0...-1].to_sym] = args[0]
  elsif Function === self[name]
    self[name].apply(self, args)
  else
    self[name]
  end
end