Class: V8::Object

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/v8/object.rb

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ Object

Returns a new instance of Object.


6
7
8
# File 'lib/v8/object.rb', line 6

def initialize(native)
  @native = native
end

Instance Method Details

#[](key) ⇒ Object


10
11
12
13
14
# File 'lib/v8/object.rb', line 10

def [](key)
  @native.context.open do
    To.ruby(@native.Get(key.to_s))        
  end
end

#[]=(key, value) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/v8/object.rb', line 16

def []=(key, value)
  value.tap do
    @native.context.open do
      @native.Set(key.to_s, value)
    end
  end
end

#eachObject


30
31
32
33
34
# File 'lib/v8/object.rb', line 30

def each
  for prop in @native.GetPropertyNames()
    yield prop, self[prop]
  end
end

#to_sObject


24
25
26
27
28
# File 'lib/v8/object.rb', line 24

def to_s
  @native.context.open do
    @native.ToString()
  end
end