Class: Sass::Script::Variable
Overview
A SassScript parse node representing a variable.
Instance Attribute Summary
- - (String) name readonly The name of the variable.
Instance Method Summary
- - (Literal) _perform(environment) protected Evaluates the variable.
- - (Array<Node>) children Returns an empty array.
- - (Variable) initialize(name) constructor A new instance of Variable.
- - (String) inspect(opts = {}) (also: #to_sass) A string representation of the variable.
Methods inherited from Node
Constructor Details
- (Variable) initialize(name)
A new instance of Variable
11 12 13 14 |
# File '/var/www/sass-pages/.haml/lib/sass/script/variable.rb', line 11
def initialize(name)
@name = name
super()
end
|
Instance Attribute Details
- (String) name (readonly)
The name of the variable.
8 9 10 |
# File '/var/www/sass-pages/.haml/lib/sass/script/variable.rb', line 8
def name
@name
end
|
Instance Method Details
- (Literal) _perform(environment) (protected)
Evaluates the variable.
38 39 40 41 42 43 44 45 |
# File '/var/www/sass-pages/.haml/lib/sass/script/variable.rb', line 38
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
|
- (Array<Node>) children
Returns an empty array.
27 28 29 |
# File '/var/www/sass-pages/.haml/lib/sass/script/variable.rb', line 27
def children
[]
end
|
- (String) inspect(opts = {}) Also known as: to_sass
A string representation of the variable
17 18 19 20 |
# File '/var/www/sass-pages/.haml/lib/sass/script/variable.rb', line 17
def inspect(opts = {})
return "!important" if name == "important"
"$#{dasherize(name, opts)}"
end
|