class Sass::Script::Tree::ListLiteral
A parse tree node representing a list literal. When resolved, this returns a {Sass::Tree::Value::List}.
Attributes
elements[R]
The parse nodes for members of this list.
@return [Array<Node>]
separator[R]
The operator separating the values of the list. Either `:comma` or `:space`.
@return [Symbol]
Public Class Methods
new(elements, separator)
click to toggle source
Creates a new list literal.
@param elements [Array<Node>] See {#elements} @param separator [Symbol] See {#separator}
# File lib/sass/script/tree/list_literal.rb, line 20 def initialize(elements, separator) @elements = elements @separator = separator end
Public Instance Methods
children()
click to toggle source
@see Sass::Script::Tree::Node#children
# File lib/sass/script/tree/list_literal.rb, line 26 def children; elements; end
deep_copy()
click to toggle source
@see Sass::Script::Tree::Node#deep_copy
# File 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!()
click to toggle source
# File lib/sass/script/tree/list_literal.rb, line 55 def force_division! # Do nothing. Lists prevent division propagation. end
inspect()
click to toggle source
# File lib/sass/script/tree/list_literal.rb, line 51 def inspect "(#{elements.map {|e| e.inspect}.join(separator == :space ? ' ' : ', ')})" end
to_sass(opts = {})
click to toggle source
@see Value#to_sass
# File 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
Protected Instance Methods
_perform(environment)
click to toggle source
# File 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