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.
8 9 10 11 |
# File 'lib/debugtrace/state.rb', line 8 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.
61 62 63 64 65 |
# File 'lib/debugtrace/state.rb', line 61 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.
19 20 21 |
# File 'lib/debugtrace/state.rb', line 19 def nest_level @nest_level end |
#previous_line_count ⇒ Object
Returns the previous line count.
29 30 31 |
# File 'lib/debugtrace/state.rb', line 29 def previous_line_count @previous_line_count end |
#previous_line_count=(value) ⇒ Object
Sets the previous line count.
35 36 37 |
# File 'lib/debugtrace/state.rb', line 35 def previous_line_count=(value) @previous_line_count = Common::check_type('value', value, Integer) end |
#previous_nest_level ⇒ Object
Returns the previous nest level.
24 25 26 |
# File 'lib/debugtrace/state.rb', line 24 def previous_nest_level @previous_nest_level end |
#reset ⇒ Object
39 40 41 42 43 44 |
# File 'lib/debugtrace/state.rb', line 39 def reset @nest_level = 0 @previous_nest_level = 0 @previous_line_count = 0 @times = [] end |
#thread_id ⇒ Object
Returns the thread id.
14 15 16 |
# File 'lib/debugtrace/state.rb', line 14 def thread_id @thread_id end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/debugtrace/state.rb', line 46 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.
51 52 53 54 55 56 57 |
# File 'lib/debugtrace/state.rb', line 51 def up_nest @previous_nest_level = @nest_level if (@nest_level >= 0) @times.push(Time.now) end @nest_level += 1 end |