Class: Parser::VariablesStack
- Inherits:
-
Object
- Object
- Parser::VariablesStack
- Defined in:
- lib/parser/variables_stack.rb
Instance Method Summary collapse
- #declare(name) ⇒ Object
- #declared?(name) ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize ⇒ VariablesStack
constructor
A new instance of VariablesStack.
- #pop ⇒ Object
- #push ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ VariablesStack
Returns a new instance of VariablesStack.
6 7 8 9 |
# File 'lib/parser/variables_stack.rb', line 6 def initialize @stack = [] push end |
Instance Method Details
#declare(name) ⇒ Object
27 28 29 |
# File 'lib/parser/variables_stack.rb', line 27 def declare(name) @stack.last << name.to_sym end |
#declared?(name) ⇒ Boolean
31 32 33 |
# File 'lib/parser/variables_stack.rb', line 31 def declared?(name) @stack.last.include?(name.to_sym) end |
#empty? ⇒ Boolean
11 12 13 |
# File 'lib/parser/variables_stack.rb', line 11 def empty? @stack.empty? end |
#pop ⇒ Object
19 20 21 |
# File 'lib/parser/variables_stack.rb', line 19 def pop @stack.pop end |
#push ⇒ Object
15 16 17 |
# File 'lib/parser/variables_stack.rb', line 15 def push @stack << Set.new end |
#reset ⇒ Object
23 24 25 |
# File 'lib/parser/variables_stack.rb', line 23 def reset @stack.clear end |