Class: RubyBreaker::Context
- Inherits:
-
Object
- Object
- RubyBreaker::Context
- Defined in:
- lib/rubybreaker/debug/context.rb
Overview
This class represents a context which consists of one or more positions. A position can refer to a physical file/line position or a virtual position with respect to an object. A context is commonly used to represent a chain of positions for types.
Instance Attribute Summary collapse
-
#child ⇒ Object
Returns the value of attribute child.
-
#pos ⇒ Object
location is either Position or ObjectPosition.
Instance Method Summary collapse
- #format_with_msg(pp, msg = "") ⇒ Object
-
#initialize(pos) ⇒ Context
constructor
A new instance of Context.
- #pop ⇒ Object
- #push(pos) ⇒ Object
Constructor Details
#initialize(pos) ⇒ Context
Returns a new instance of Context.
81 82 83 84 |
# File 'lib/rubybreaker/debug/context.rb', line 81 def initialize(pos) @pos = pos @child = nil end |
Instance Attribute Details
#child ⇒ Object
Returns the value of attribute child.
79 80 81 |
# File 'lib/rubybreaker/debug/context.rb', line 79 def child @child end |
#pos ⇒ Object
location is either Position or ObjectPosition
78 79 80 |
# File 'lib/rubybreaker/debug/context.rb', line 78 def pos @pos end |
Instance Method Details
#format_with_msg(pp, msg = "") ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/rubybreaker/debug/context.rb', line 104 def format_with_msg(pp,msg="") pp.text(@pos.to_s) pp.breakable() if @child pp.group(2) { pp.breakable() @child.format_with_msg(pp,msg) } elsif msg != "" pp.group(2) do pp.breakable() pp.text("> #{msg}",79) end end end |
#pop ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/rubybreaker/debug/context.rb', line 94 def pop if @child && @child.child @child.pop elsif @child @child = nil else # root; don't do anything end end |