Class: State

Inherits:
Object
  • Object
show all
Defined in:
lib/debugtrace/state.rb

Overview

Have the trace state for a thread

Instance Method Summary collapse

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_nestObject

Downs the nest level.

Returns:

  • Time: The time when the corresponding upNest method was invoked



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_levelObject

Returns the nest level.

Returns:

  • the nest level.



18
19
20
# File 'lib/debugtrace/state.rb', line 18

def nest_level
  @nest_level
end

#previous_line_countObject

Returns the previous line count.

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.

Parameters:

  • value

    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_levelObject

Returns the previous nest level.

Returns:

  • the previous nest level.



23
24
25
# File 'lib/debugtrace/state.rb', line 23

def previous_nest_level
  @previous_nest_level
end

#resetObject



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_idObject

Returns the thread id.

Returns:

  • the thread id.



13
14
15
# File 'lib/debugtrace/state.rb', line 13

def thread_id
  @thread_id
end

#to_sObject



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_nestObject

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