Class: State
- Inherits:
-
Object
- Object
- State
- Defined in:
- lib/debugtrace/state.rb
Overview
Have the trace state for a thread
Instance Attribute Summary collapse
-
#nest_level ⇒ Object
readonly
Returns the value of attribute nest_level.
-
#previous_nest_level ⇒ Object
readonly
Returns the value of attribute previous_nest_level.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
Instance Method Summary collapse
-
#down_nest ⇒ Object
Downs the nest level.
-
#initialize(thread_id) ⇒ State
constructor
A new instance of State.
- #reset ⇒ Object
- #to_s ⇒ Object
-
#up_nest ⇒ Object
Ups the nest level.
Constructor Details
#initialize(thread_id) ⇒ State
Returns a new instance of State.
12 13 14 15 |
# File 'lib/debugtrace/state.rb', line 12 def initialize(thread_id) @thread_id = thread_id reset() end |
Instance Attribute Details
#nest_level ⇒ Object (readonly)
Returns the value of attribute nest_level.
9 10 11 |
# File 'lib/debugtrace/state.rb', line 9 def nest_level @nest_level end |
#previous_nest_level ⇒ Object (readonly)
Returns the value of attribute previous_nest_level.
10 11 12 |
# File 'lib/debugtrace/state.rb', line 10 def previous_nest_level @previous_nest_level end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
8 9 10 |
# File 'lib/debugtrace/state.rb', line 8 def thread_id @thread_id end |
Instance Method Details
#down_nest ⇒ Object
Downs the nest level.
39 40 41 42 43 |
# File 'lib/debugtrace/state.rb', line 39 def down_nest @previous_nest_level = @nest_level @nest_level -= 1 return @times.length > 0 ? @times.pop() : Time.now end |
#reset ⇒ Object
17 18 19 20 21 |
# File 'lib/debugtrace/state.rb', line 17 def reset @nest_level = 0 @previous_nest_level = 0 @times = [] end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/debugtrace/state.rb', line 23 def to_s() return "(State){thread_id: #{@thread_id}, nest_level: #{@nest_level}, previous_nest_level: #{@previous_nest_level}, times: #{@times}}" end |
#up_nest ⇒ Object
Ups the nest level.
28 29 30 31 32 33 34 35 |
# File 'lib/debugtrace/state.rb', line 28 def up_nest @previous_nest_level = @nest_level if (@nest_level >= 0) @times.push(Time.now) end @nest_level += 1 return nil end |