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(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(name) ⇒ Stack
Set up the stack.
16 17 18 19 20 |
# File 'lib/gloo/exec/stack.rb', line 16 def initialize( name ) @name = name clear_stack $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.
71 72 73 74 |
# File 'lib/gloo/exec/stack.rb', line 71 def clear_stack @stack = [] self.update_out_file end |
#out_data ⇒ Object
Get stack data for output.
50 51 52 |
# File 'lib/gloo/exec/stack.rb', line 50 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.
57 58 59 |
# File 'lib/gloo/exec/stack.rb', line 57 def out_file return File.join( $settings.debug_path, @name ) end |
#pop ⇒ Object
Pop an item from the stack.
34 35 36 37 38 |
# File 'lib/gloo/exec/stack.rb', line 34 def pop o = @stack.pop $log.debug "#{@name}:pop #{o.display_value}" self.update_out_file if $settings.debug end |
#push(obj) ⇒ Object
Push an item onto the stack.
25 26 27 28 29 |
# File 'lib/gloo/exec/stack.rb', line 25 def push( obj ) $log.debug "#{@name}:push #{obj.display_value}" @stack.push obj self.update_out_file if $settings.debug end |
#size ⇒ Object
Get the current size of the call stack.
43 44 45 |
# File 'lib/gloo/exec/stack.rb', line 43 def size return @stack.size end |
#update_out_file ⇒ Object
Update the stack trace file.
64 65 66 |
# File 'lib/gloo/exec/stack.rb', line 64 def update_out_file File.write( self.out_file, self.out_data ) end |