Class: Ripper::RubyBuilder::Stack
- Defined in:
- lib/ripper/ruby_builder/stack.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #_pop ⇒ Object
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #pop(*types) ⇒ Object
- #push(token) ⇒ Object
Methods inherited from Array
Constructor Details
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
47 48 49 |
# File 'lib/ripper/ruby_builder/stack.rb', line 47 def buffer @buffer end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
47 48 49 |
# File 'lib/ripper/ruby_builder/stack.rb', line 47 def queue @queue end |
Instance Method Details
#_pop ⇒ Object
62 |
# File 'lib/ripper/ruby_builder/stack.rb', line 62 alias :_pop :pop |
#pop(*types) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ripper/ruby_builder/stack.rb', line 63 def pop(*types) = types.last.is_a?(::Hash) ? types.pop : {} max, pass, revert = .delete_at(:max, :pass, :reverse) ignored, tokens = [], [] reverse! if revert while !empty? && !(max && tokens.length >= max) if types.include?(last.type) && matches?() tokens << _pop() elsif last.opener? && !pass break else ignored.unshift(_pop()) end end replace(self + ignored) reverse! if revert tokens end |
#push(token) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/ripper/ruby_builder/stack.rb', line 54 def push(token) return token if buffer.aggregate(token) tokens = queue << token tokens.each do |token| self << token end end |