Class: Sass::Script::Variable
- Inherits:
-
Node
- Object
- Node
- Sass::Script::Variable
- Defined in:
- /var/www/sass-pages/.sass/lib/sass/script/variable.rb
Overview
A SassScript parse node representing a variable.
Instance Attribute Summary
- - (String) name readonly The name of the variable.
- - (String) underscored_name readonly The underscored name of the variable.
Instance Method Summary
- - (Literal) _perform(environment) protected Evaluates the variable.
- - (Array<Node>) children Returns an empty array.
- - deep_copy
- - (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
16 17 18 19 20 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 16
def initialize(name)
@name = name
@underscored_name = name.gsub(/-/,"_")
super()
end
|
Instance Attribute Details
- (String) name (readonly)
The name of the variable.
8 9 10 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 8
def name
@name
end
|
- (String) underscored_name (readonly)
The underscored name of the variable.
13 14 15 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 13
def underscored_name
@underscored_name
end
|
Instance Method Details
- (Literal) _perform(environment) (protected)
Evaluates the variable.
48 49 50 51 52 53 54 55 |
# File '/var/www/sass-pages/.sass/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
|
- (Array<Node>) children
Returns an empty array.
32 33 34 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 32
def children
[]
end
|
- deep_copy
37 38 39 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 37
def deep_copy
dup
end
|
- (String) inspect(opts = {}) Also known as: to_sass
A string representation of the variable
23 24 25 |
# File '/var/www/sass-pages/.sass/lib/sass/script/variable.rb', line 23
def inspect(opts = {})
"$#{dasherize(name, opts)}"
end
|