Class Sass::Environment
In: lib/sass/environment.rb
Parent: Object
Haml::Util Engine Color SyntaxError UnitConversionError StandardError Node Operation Literal UnaryOperation Funcall Variable Number String Bool EvaluationContext Node\n[lib/sass/css.rb\nlib/sass/tree/node.rb] DebugNode IfNode CommentNode ForNode MixinNode VariableNode ImportNode WhileNode MixinDefNode Repl CSS Environment Lexer Parser PropNode\n[lib/sass/css.rb\nlib/sass/tree/prop_node.rb] DirectiveNode\n[lib/sass/css.rb\nlib/sass/tree/directive_node.rb] RuleNode\n[lib/sass/css.rb\nlib/sass/tree/rule_node.rb] Rack lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/literal.rb lib/sass/script/node.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script Files lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb Plugin Sass dot/m_54_0.png

The lexical environment for SassScript. This keeps track of variable and mixin 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 {Sass::Script::Functions}.

Methods

inherited_hash   new   options  

Attributes

options  [W] 
parent  [R]  The enclosing environment, or nil if this is the global environment.

@return [Environment]

Public Class methods

@param parent [Environment] See \{parent}

[Source]

    # File lib/sass/environment.rb, line 22
22:     def initialize(parent = nil)
23:       @vars = {}
24:       @mixins = {}
25:       @parent = parent
26: 
27:       set_var("important", Script::String.new("!important")) unless @parent
28:     end

Private Class methods

Note: when updating this, update haml/yard/inherited_hash.rb as well.

[Source]

    # File lib/sass/environment.rb, line 43
43:       def inherited_hash(name)
44:         class_eval "          def \#{name}(name)\n            @\#{name}s[name] || @parent && @parent.\#{name}(name)\n          end\n\n          def set_\#{name}(name, value)\n            @\#{name}s[name] = value unless try_set_\#{name}(name, value)\n          end\n\n          def try_set_\#{name}(name, value)\n            if @\#{name}s.include?(name)\n              @\#{name}s[name] = value\n              true\n            elsif @parent\n              @parent.try_set_\#{name}(name, value)\n            else\n              false\n            end\n          end\n          protected :try_set_\#{name}\n\n          def set_local_\#{name}(name, value)\n            @\#{name}s[name] = value\n          end\n", __FILE__, __LINE__ + 1
45:       end

Public Instance methods

The options hash. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@return [{Symbol => Object}]

[Source]

    # File lib/sass/environment.rb, line 34
34:     def options
35:       @options || (parent && parent.options) || {}
36:     end

[Validate]