Class: Sass::Script::Tree::ListLiteral
- Inherits:
- Node
- Object
- Node
- Sass::Script::Tree::ListLiteral
show all - Defined in:
- /Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb
Overview
A parse tree node representing a list literal. When resolved, this returns a Tree::Value::List.
Instance Attribute Summary (collapse)
Attributes inherited from Node
#css_variable_warning, #filename, #line, #options, #source_range
Instance Method Summary (collapse)
Methods inherited from Node
#dasherize, #opts, #perform
Constructor Details
- (ListLiteral) initialize(elements, separator)
Creates a new list literal.
20
21
22
23 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 20
def initialize(elements, separator)
@elements = elements
@separator = separator
end |
Instance Attribute Details
- (Array<Node>) elements
The parse nodes for members of this list.
8
9
10 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 8
def elements
@elements
end |
- (Symbol) separator
The operator separating the values of the list. Either :comma
or :space
.
14
15
16 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 14
def separator
@separator
end |
Instance Method Details
61
62
63
64
65
66
67
68 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 61
def _perform(environment)
list = Sass::Script::Value::List.new(
elements.map {|e| e.perform(environment)},
separator)
list.source_range = source_range
list.options = options
list
end |
- children
26 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 26
def children; elements; end |
- deep_copy
45
46
47
48
49 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 45
def deep_copy
node = dup
node.instance_variable_set('@elements', elements.map {|e| e.deep_copy})
node
end |
- force_division!
55
56
57 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 55
def force_division!
# Do nothing. Lists prevent division propagation.
end |
- inspect
51
52
53 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 51
def inspect
"(#{elements.map {|e| e.inspect}.join(separator == :space ? ' ' : ', ')})"
end |
- to_sass(opts = {})
29
30
31
32
33
34
35
36
37
38
39
40
41
42 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/tree/list_literal.rb', line 29
def to_sass(opts = {})
return "()" if elements.empty?
members = elements.map do |v|
if element_needs_parens?(v)
"(#{v.to_sass(opts)})"
else
v.to_sass(opts)
end
end
return "(#{members.first},)" if separator == :comma && members.length == 1
members.join(sep_str(nil))
end |