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.
14 15 16 17 |
# File 'lib/debugtrace/state.rb', line 14 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.
8 9 10 |
# File 'lib/debugtrace/state.rb', line 8 def nest_level @nest_level end |
#previous_nest_level ⇒ Object (readonly)
Returns the value of attribute previous_nest_level.
9 10 11 |
# File 'lib/debugtrace/state.rb', line 9 def previous_nest_level @previous_nest_level end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
7 8 9 |
# File 'lib/debugtrace/state.rb', line 7 def thread_id @thread_id end |
Instance Method Details
#down_nest ⇒ Float
Downs the nest level.
45 46 47 48 49 |
# File 'lib/debugtrace/state.rb', line 45 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
20 21 22 23 24 |
# File 'lib/debugtrace/state.rb', line 20 def reset @nest_level = 0 @previous_nest_level = 0 @times = [] end |
#to_s ⇒ String
Returns a string representation of this object.
29 30 31 |
# File 'lib/debugtrace/state.rb', line 29 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.
34 35 36 37 38 39 40 |
# File 'lib/debugtrace/state.rb', line 34 def up_nest @previous_nest_level = @nest_level if (@nest_level >= 0) @times.push(Time.now) end @nest_level += 1 end |