class Sass::Script::Tree::Variable
A SassScript parse node representing a variable.
Attributes
name[R]
The name of the variable.
@return [String]
underscored_name[R]
The underscored name of the variable.
@return [String]
Public Class Methods
new(name)
click to toggle source
@param name [String] See {#name}
Calls superclass method
# File lib/sass/script/tree/variable.rb, line 15 def initialize(name) @name = name @underscored_name = name.gsub(/-/, "_") super() end
Public Instance Methods
children()
click to toggle source
Returns an empty array.
@return [Array<Node>] empty @see Sass::Script::Tree::Node#children
# File lib/sass/script/tree/variable.rb, line 31 def children [] end
deep_copy()
click to toggle source
@see Sass::Script::Tree::Node#deep_copy
# File lib/sass/script/tree/variable.rb, line 36 def deep_copy dup end
inspect(opts = {})
click to toggle source
@return [String] A string representation of the variable
# File lib/sass/script/tree/variable.rb, line 22 def inspect(opts = {}) "$#{dasherize(name, opts)}" end
Also aliased as: to_sass
Protected Instance Methods
_perform(environment)
click to toggle source
Evaluates the variable.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Sass::Script::Value] The SassScript object that is the value of the variable @raise [Sass::SyntaxError] if the variable is undefined
# File lib/sass/script/tree/variable.rb, line 47 def _perform(environment) val = environment.var(name) raise Sass::SyntaxError.new("Undefined variable: \"$#{name}\".") unless val if val.is_a?(Sass::Script::Value::Number) && val.original val = val.dup val.original = nil end val end