Class: V8::StackTrace

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

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ StackTrace

Returns a new instance of StackTrace



7
8
9
10
# File 'lib/v8/stack.rb', line 7

def initialize(native)
  @context = V8::Context.current
  @native = native
end

Instance Method Details

#eachObject



18
19
20
21
22
23
24
25
# File 'lib/v8/stack.rb', line 18

def each
  return unless @native
  @context.enter do
    for i in 0..length - 1
      yield V8::StackFrame.new(@native.GetFrame(i), @context)
    end
  end
end

#lengthObject



12
13
14
15
16
# File 'lib/v8/stack.rb', line 12

def length
  @context.enter do
    @native ? @native.GetFrameCount() : 0
  end
end

#to_sObject



27
28
29
# File 'lib/v8/stack.rb', line 27

def to_s
  @native ? map(&:to_s).join("\n") : ""
end