class RubyLint::NestedStack

{RubyLint::NestedStack} is a basic implementation of a nested stack. It's primarily used by {RubyLint::VirtualMachine} for storing variables and values during assignments.

Public Class Methods

new() click to toggle source
# File lib/ruby-lint/nested_stack.rb, line 8
def initialize
  @values = []
end

Public Instance Methods

add_stack() click to toggle source

Adds a new stack to push values to.

# File lib/ruby-lint/nested_stack.rb, line 15
def add_stack
  @values << []
end
empty?() click to toggle source

Returns `true` if the stack is empty.

@return [TrueClass|FalseClass]

# File lib/ruby-lint/nested_stack.rb, line 24
def empty?
  return @values.empty?
end
pop() click to toggle source

Pops the last stack from the collection and returns it.

@return [Array]

# File lib/ruby-lint/nested_stack.rb, line 42
def pop
  return @values.pop
end
push(value) click to toggle source

Pushes a value to the current (= last) stack.

@param [Mixed] value

# File lib/ruby-lint/nested_stack.rb, line 33
def push(value)
  @values.last << value
end