Class: Sass::Script::Tree::Variable

Inherits:
Node
  • Object
show all
Defined in:
/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/variable.rb

Overview

A SassScript parse node representing a variable.

Instance Attribute Summary (collapse)

Attributes inherited from Node

#filename, #line, #options, #source_range

Instance Method Summary (collapse)

Methods inherited from Node

#dasherize, #force_division!, #opts, #perform

Constructor Details

- (Variable) initialize(name)

Returns a new instance of Variable

Parameters:

  • name (String)

    See #name



15
16
17
18
19
# File '/home/nweiz/code/sass-site/.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.

Returns:

  • (String)


7
8
9
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/variable.rb', line 7

def name
  @name
end

- (String) underscored_name (readonly)

The underscored name of the variable.

Returns:

  • (String)


12
13
14
# File '/home/nweiz/code/sass-site/.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.

Parameters:

  • environment (Sass::Environment)

    The environment in which to evaluate the SassScript

Returns:

Raises:



47
48
49
50
51
52
53
54
55
# File '/home/nweiz/code/sass-site/.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.

Returns:

  • (Array<Node>)

    empty

See Also:



31
32
33
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/variable.rb', line 31

def children
  []
end

- deep_copy

See Also:



36
37
38
# File '/home/nweiz/code/sass-site/.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

Returns:

  • (String)

    A string representation of the variable



22
23
24
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/variable.rb', line 22

def inspect(opts = {})
  "$#{dasherize(name, opts)}"
end