Class: State
- Inherits:
-
Object
- Object
- State
- Defined in:
- lib/debugtrace/state.rb
Overview
Contains 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 ⇒ Float
Downs the nest level.
-
#initialize(thread_id) ⇒ State
constructor
Initializes this object.
-
#reset ⇒ Object
Resets this object.
-
#to_s ⇒ String
Returns a string representation of this object.
-
#up_nest ⇒ Object
Ups the nest level.
Constructor Details
#initialize(thread_id) ⇒ State
Initializes this object.
15 16 17 18 |
# File 'lib/debugtrace/state.rb', line 15 def initialize(thread_id) @thread_id = Common.check_type('thread_id', thread_id, Integer) 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 ⇒ Float
Downs the nest level.
46 47 48 49 50 |
# File 'lib/debugtrace/state.rb', line 46 def down_nest @previous_nest_level = @nest_level @nest_level -= 1 return @times.length > 0 ? @times.pop() : Time.now end |
#reset ⇒ Object
Resets this object
21 22 23 24 25 |
# File 'lib/debugtrace/state.rb', line 21 def reset @nest_level = 0 @previous_nest_level = 0 @times = [] end |
#to_s ⇒ String
Returns a string representation of this object.
30 31 32 |
# File 'lib/debugtrace/state.rb', line 30 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.
35 36 37 38 39 40 41 |
# File 'lib/debugtrace/state.rb', line 35 def up_nest @previous_nest_level = @nest_level if (@nest_level >= 0) @times.push(Time.now) end @nest_level += 1 end |