Class: Sass::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/stack.rb

Overview

A class representing the stack when compiling a Sass file.

Defined Under Namespace

Classes: Frame

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



69
70
71
# File 'lib/sass/stack.rb', line 69

def initialize
  @frames = []
end

Instance Attribute Details

#framesArray<Frame> (readonly)

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

Returns:



67
68
69
# File 'lib/sass/stack.rb', line 67

def frames
  @frames
end

Instance Method Details

#to_s



101
102
103
104
105
106
107
108
# File 'lib/sass/stack.rb', line 101

def to_s
  Sass::Util.enum_with_index(Sass::Util.enum_cons(frames.reverse + [nil], 2)).
      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) { ... }

Pushes a base frame onto the stack.

Parameters:

Yields:

  • [] A block in which the new frame is on the stack.



78
79
80
# File 'lib/sass/stack.rb', line 78

def with_base(filename, line)
  with_frame(filename, line, :base) {yield}
end

#with_import(filename, line) { ... }

Pushes an import frame onto the stack.

Parameters:

Yields:

  • [] A block in which the new frame is on the stack.



87
88
89
# File 'lib/sass/stack.rb', line 87

def with_import(filename, line)
  with_frame(filename, line, :import) {yield}
end

#with_mixin(filename, line, name) { ... }

Pushes a mixin frame onto the stack.

Parameters:

Yields:

  • [] A block in which the new frame is on the stack.



97
98
99
# File 'lib/sass/stack.rb', line 97

def with_mixin(filename, line, name)
  with_frame(filename, line, :mixin, name) {yield}
end