Class: Sass::Script::Tree::Variable
- Inherits:
-  Node - Object
- Node
- Sass::Script::Tree::Variable
 
- Defined in:
- /Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb
Overview
A SassScript parse node representing a variable.
Instance Attribute Summary (collapse)
-   - (String) name   readonly The name of the variable. 
-   - (String) underscored_name   readonly The underscored name of the variable. 
Attributes inherited from Node
#css_variable_warning, #filename, #line, #options, #source_range
Instance Method Summary (collapse)
-   - (Sass::Script::Value) _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
#dasherize, #force_division!, #opts, #perform
Constructor Details
- (Variable) initialize(name)
Returns a new instance of Variable
| 15 16 17 18 19 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 15
def initialize(name)
  @name = name
  @underscored_name = name.tr("-", "_")
  super()
end | 
Instance Attribute Details
- (String) name (readonly)
The name of the variable.
| 7 8 9 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 7
def name
  @name
end | 
- (String) underscored_name (readonly)
The underscored name of the variable.
| 12 13 14 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 12
def underscored_name
  @underscored_name
end | 
Instance Method Details
- (Sass::Script::Value) _perform(environment) (protected)
Evaluates the variable.
| 47 48 49 50 51 52 53 54 55 | # File '/Users/ceppstei/Projects/sass-lang/.sass/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 | 
- (Array<Node>) children
Returns an empty array.
| 31 32 33 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 31
def children
  []
end | 
- deep_copy
| 36 37 38 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 36
def deep_copy
  dup
end | 
- (String) inspect(opts = {}) Also known as: to_sass
Returns A string representation of the variable
| 22 23 24 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/variable.rb', line 22
def inspect(opts = {})
  "$#{dasherize(name, opts)}"
end |