class Sass::Script::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/variable.rb, line 16 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::Node#children
# File lib/sass/script/variable.rb, line 32 def children [] end
deep_copy()
click to toggle source
@see Sass::Script::Node#deep_copy
# File lib/sass/script/variable.rb, line 37 def deep_copy dup end
inspect(opts = {})
click to toggle source
@return [String] A string representation of the variable
# File lib/sass/script/variable.rb, line 23 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 [Literal] The SassScript object that is the value of the variable @raise [Sass::SyntaxError] if the variable is undefined
# File lib/sass/script/variable.rb, line 48 def _perform(environment) raise SyntaxError.new("Undefined variable: \"$#{name}\".") unless val = environment.var(name) if val.is_a?(Number) val = val.dup val.original = nil end return val end