# class Sass::Stack

A class representing the stack when compiling a Sass file.

### Attributes

frames[R]

The stack frames. The last frame is the most deeply-nested.

@return [Array<Frame>]

### Public Class Methods

new() click to toggle source

    # File lib/sass/stack.rb, line 69
    def initialize
      @frames = []
    end

### Public Instance Methods

to_s() click to toggle source

    # File lib/sass/stack.rb, line 121
    def to_s
      (frames.reverse + [nil]).each_cons(2).each_with_index.
          map do |(frame, caller), i|
        "#{i == 0 ? 'on' : 'from'} line #{frame.line}" +
          " of #{frame.filename || 'an unknown file'}" +
          (caller && caller.name ? ", in `#{caller.name}'" : "")
      end.join("\n")
    end

with_base(filename, line) { || ... } click to toggle source

Pushes a base frame onto the stack.

@param filename [String] See {Frame#filename}. @param line [String] See {Frame#line}. @yield [] A block in which the new frame is on the stack.

    # File lib/sass/stack.rb, line 78
    def with_base(filename, line)
      with_frame(filename, line, :base) {yield}
    end

with_directive(filename, line, name) { || ... } click to toggle source

Pushes a function frame onto the stack.

@param filename [String] See {Frame#filename}. @param line [String] See {Frame#line}. @param name [String] See {Frame#name}. @yield [] A block in which the new frame is on the stack.

    # File lib/sass/stack.rb, line 117
    def with_directive(filename, line, name)
      with_frame(filename, line, :directive, name) {yield}
    end

with_function(filename, line, name) { || ... } click to toggle source

Pushes a function frame onto the stack.

@param filename [String] See {Frame#filename}. @param line [String] See {Frame#line}. @param name [String] See {Frame#name}. @yield [] A block in which the new frame is on the stack.

    # File lib/sass/stack.rb, line 107
    def with_function(filename, line, name)
      with_frame(filename, line, :function, name) {yield}
    end

with_import(filename, line) { || ... } click to toggle source

Pushes an import frame onto the stack.

@param filename [String] See {Frame#filename}. @param line [String] See {Frame#line}. @yield [] A block in which the new frame is on the stack.

    # File lib/sass/stack.rb, line 87
    def with_import(filename, line)
      with_frame(filename, line, :import) {yield}
    end

with_mixin(filename, line, name) { || ... } click to toggle source

Pushes a mixin frame onto the stack.

@param filename [String] See {Frame#filename}. @param line [String] See {Frame#line}. @param name [String] See {Frame#name}. @yield [] A block in which the new frame is on the stack.

    # File lib/sass/stack.rb, line 97
    def with_mixin(filename, line, name)
      with_frame(filename, line, :mixin, name) {yield}
    end

### Private Instance Methods

with_frame(filename, line, type, name = nil) { || ... } click to toggle source

    # File lib/sass/stack.rb, line 132
    def with_frame(filename, line, type, name = nil)
      @frames.pop if @frames.last && @frames.last.type == :base
      @frames.push(Frame.new(filename, line, type, name))
      yield
    ensure
      @frames.pop unless type == :base && @frames.last && @frames.last.type != :base
    end