Class: State
- Inherits:
-
Object
- Object
- State
- Defined in:
- lib/debugtrace/state.rb
Overview
Have the trace state for a thread
Instance Method Summary collapse
-
#down_nest ⇒ Object
Downs the nest level.
-
#initialize(thread_id) ⇒ State
constructor
A new instance of State.
-
#nest_level ⇒ Object
The nest level.
-
#previous_line_count ⇒ Object
The previous line count.
-
#previous_line_count=(value) ⇒ Object
Sets the previous line count.
-
#previous_nest_level ⇒ Object
The previous nest level.
- #reset ⇒ Object
-
#thread_id ⇒ Object
The thread id.
- #to_s ⇒ Object
-
#up_nest ⇒ Object
Ups the nest level.
Constructor Details
#initialize(thread_id) ⇒ State
Returns a new instance of State.
7 8 9 10 |
# File 'lib/debugtrace/state.rb', line 7 def initialize(thread_id) @thread_id = Common::check_type('thread_id', thread_id, Integer) reset() end |
Instance Method Details
#down_nest ⇒ Object
Downs the nest level.
60 61 62 63 64 |
# File 'lib/debugtrace/state.rb', line 60 def down_nest @previous_nest_level = @nest_level @nest_level -= 1 return @times.length > 0 ? @times.pop() : Time.now end |
#nest_level ⇒ Object
Returns the nest level.
18 19 20 |
# File 'lib/debugtrace/state.rb', line 18 def nest_level @nest_level end |
#previous_line_count ⇒ Object
Returns the previous line count.
28 29 30 |
# File 'lib/debugtrace/state.rb', line 28 def previous_line_count @previous_line_count end |
#previous_line_count=(value) ⇒ Object
Sets the previous line count.
34 35 36 |
# File 'lib/debugtrace/state.rb', line 34 def previous_line_count=(value) @previous_line_count = Common::check_type('value', value, Integer) end |
#previous_nest_level ⇒ Object
Returns the previous nest level.
23 24 25 |
# File 'lib/debugtrace/state.rb', line 23 def previous_nest_level @previous_nest_level end |
#reset ⇒ Object
38 39 40 41 42 43 |
# File 'lib/debugtrace/state.rb', line 38 def reset @nest_level = 0 @previous_nest_level = 0 @previous_line_count = 0 @times = [] end |
#thread_id ⇒ Object
Returns the thread id.
13 14 15 |
# File 'lib/debugtrace/state.rb', line 13 def thread_id @thread_id end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/debugtrace/state.rb', line 45 def to_s() "(State){thread_id: #{@thread_id}, nest_level: #{@nest_level}, previous_nest_level: #{@previous_nest_level}, previous_line_count: #{@previous_line_count}, times: #{@times}}" end |
#up_nest ⇒ Object
Ups the nest level.
50 51 52 53 54 55 56 |
# File 'lib/debugtrace/state.rb', line 50 def up_nest @previous_nest_level = @nest_level if (@nest_level >= 0) @times.push(Time.now) end @nest_level += 1 end |