Class: Gloo::Exec::Stack
- Inherits:
-
Object
- Object
- Gloo::Exec::Stack
- Defined in:
- lib/gloo/exec/stack.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
-
#clear_stack ⇒ Object
Clear the stack and the output file.
-
#initialize(engine, name) ⇒ Stack
constructor
Set up the stack.
-
#out_data ⇒ Object
Get stack data for output.
-
#out_file ⇒ Object
Get the file we’ll write debug information for the stack.
-
#pop ⇒ Object
Pop an item from the stack.
-
#push(obj) ⇒ Object
Push an item onto the stack.
-
#size ⇒ Object
Get the current size of the call stack.
-
#update_out_file ⇒ Object
Update the stack trace file.
Constructor Details
#initialize(engine, name) ⇒ Stack
Set up the stack.
16 17 18 19 20 21 |
# File 'lib/gloo/exec/stack.rb', line 16 def initialize( engine, name ) @engine = engine @name = name clear_stack @engine.log.debug "#{name} stack intialized..." end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
11 12 13 |
# File 'lib/gloo/exec/stack.rb', line 11 def stack @stack end |
Instance Method Details
#clear_stack ⇒ Object
Clear the stack and the output file.
72 73 74 75 |
# File 'lib/gloo/exec/stack.rb', line 72 def clear_stack @stack = [] self.update_out_file end |
#out_data ⇒ Object
Get stack data for output.
51 52 53 |
# File 'lib/gloo/exec/stack.rb', line 51 def out_data return @stack.map( &:display_value ).join( "\n" ) end |
#out_file ⇒ Object
Get the file we’ll write debug information for the stack.
58 59 60 |
# File 'lib/gloo/exec/stack.rb', line 58 def out_file return File.join( @engine.settings.debug_path, @name ) end |
#pop ⇒ Object
Pop an item from the stack.
35 36 37 38 39 |
# File 'lib/gloo/exec/stack.rb', line 35 def pop o = @stack.pop @engine.log.debug "#{@name}:pop #{o.display_value}" self.update_out_file if @engine.settings.debug end |
#push(obj) ⇒ Object
Push an item onto the stack.
26 27 28 29 30 |
# File 'lib/gloo/exec/stack.rb', line 26 def push( obj ) @engine.log.debug "#{@name}:push #{obj.display_value}" @stack.push obj self.update_out_file if @engine.settings.debug end |
#size ⇒ Object
Get the current size of the call stack.
44 45 46 |
# File 'lib/gloo/exec/stack.rb', line 44 def size return @stack.size end |
#update_out_file ⇒ Object
Update the stack trace file.
65 66 67 |
# File 'lib/gloo/exec/stack.rb', line 65 def update_out_file File.write( self.out_file, self.out_data ) end |