Class: Sass::Environment
- Inherits:
-
Object
- Object
- Sass::Environment
- Defined in:
- lib/sass/environment.rb
Overview
The lexical environment for SassScript. This keeps track of variable, mixin, and function definitions.
A new environment is created for each level of Sass nesting. This allows variables to be lexically scoped. The new environment refers to the environment in the upper scope, so it has access to variables defined in enclosing scopes, but new variables are defined locally.
Environment also keeps track of the Engine options so that they can be made available to Script::Functions.
Instance Attribute Summary collapse
-
#caller ⇒ Environment?
The environment of the caller of this environment's mixin or function.
-
#content ⇒ Environment?
The content passed to this environmnet.
-
#options
readonly
Returns the value of attribute options.
-
#parent ⇒ Environment
readonly
The enclosing environment, or nil if this is the global environment.
Instance Method Summary collapse
-
#initialize(parent = nil, options = nil) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(parent = nil, options = nil) ⇒ Environment
Returns a new instance of Environment.
28 29 30 31 |
# File 'lib/sass/environment.rb', line 28
def initialize(parent = nil, options = nil)
@parent = parent
@options = options || (parent && parent.options) || {}
end
|
Instance Attribute Details
#caller ⇒ Environment?
The environment of the caller of this environment's mixin or function.
35 36 37 |
# File 'lib/sass/environment.rb', line 35
def caller
@caller || (@parent && @parent.caller)
end
|
#content ⇒ Environment?
The content passed to this environmnet. This is naturally only set for mixin body environments with content passed in.
42 43 44 |
# File 'lib/sass/environment.rb', line 42
def content
@content || (@parent && @parent.content)
end
|
#options (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/sass/environment.rb', line 21
def options
@options
end
|
#parent ⇒ Environment (readonly)
The enclosing environment, or nil if this is the global environment.
20 21 22 |
# File 'lib/sass/environment.rb', line 20
def parent
@parent
end
|