Class: Vernier::StackTableHelpers::Stack
- Inherits:
-
BaseType
- Object
- BaseType
- Vernier::StackTableHelpers::Stack
show all
- Defined in:
- lib/vernier/stack_table_helpers.rb
Instance Attribute Summary
Attributes inherited from BaseType
#idx, #stack_table
Instance Method Summary
collapse
Methods inherited from BaseType
#initialize, #inspect
Instance Method Details
#[](offset) ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/vernier/stack_table_helpers.rb', line 116
def [](offset)
raise RangeError if offset < 0
stack_idx = idx
while stack_idx && offset > 0
stack_idx = stack_table.stack_parent_idx(stack_idx)
offset -= 1
end
if stack_idx && offset == 0
Frame.new(stack_table, stack_table.stack_frame_idx(stack_idx))
end
end
|
#each ⇒ Object
Also known as:
each_frame
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/vernier/stack_table_helpers.rb', line 104
def each
return enum_for(__method__) unless block_given?
stack_idx = idx
while stack_idx
frame_idx = stack_table.stack_frame_idx(stack_idx)
yield Frame.new(stack_table, frame_idx)
stack_idx = stack_table.stack_parent_idx(stack_idx)
end
end
|
#frames ⇒ Object
136
137
138
|
# File 'lib/vernier/stack_table_helpers.rb', line 136
def frames
each_frame.to_a
end
|
#leaf_frame ⇒ Object
132
133
134
|
# File 'lib/vernier/stack_table_helpers.rb', line 132
def leaf_frame
Frame.new(stack_table, leaf_frame_idx)
end
|
#leaf_frame_idx ⇒ Object
128
129
130
|
# File 'lib/vernier/stack_table_helpers.rb', line 128
def leaf_frame_idx
stack_table.stack_frame_idx(idx)
end
|
#to_s ⇒ Object
140
141
142
143
144
145
146
|
# File 'lib/vernier/stack_table_helpers.rb', line 140
def to_s
arr = []
each_frame do |frame|
arr << frame.to_s
end
arr.join("\n")
end
|