/usr/lib/ruby/vendor_ruby/sass/script/list.rb is in ruby-sass 3.1.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | module Sass::Script
# A SassScript object representing a CSS list.
# This includes both comma-separated lists and space-separated lists.
class List < Literal
# The Ruby array containing the contents of the list.
#
# @return [Array<Literal>]
attr_reader :value
alias_method :children, :value
alias_method :to_a, :value
# The operator separating the values of the list.
# Either `:comma` or `:space`.
#
# @return [Symbol]
attr_reader :separator
# Creates a new list.
#
# @param value [Array<Literal>] See \{#value}
# @param separator [String] See \{#separator}
def initialize(value, separator)
super(value)
@separator = separator
end
# @see Node#deep_copy
def deep_copy
node = dup
node.instance_variable_set('@value', value.map {|c| c.deep_copy})
node
end
# @see Node#eq
def eq(other)
Sass::Script::Bool.new(
self.class == other.class && self.value == other.value &&
self.separator == other.separator)
end
# @see Node#to_s
def to_s(opts = {})
raise Sass::SyntaxError.new("() isn't a valid CSS value.") if value.empty?
return value.reject {|e| e.is_a?(List) && e.value.empty?}.map {|e| e.to_s(opts)}.join(sep_str)
end
# @see Node#to_sass
def to_sass(opts = {})
precedence = Sass::Script::Parser.precedence_of(separator)
value.map do |v|
if v.is_a?(List) && Sass::Script::Parser.precedence_of(v.separator) <= precedence
"(#{v.to_sass(opts)})"
else
v.to_sass(opts)
end
end.join(sep_str(nil))
end
# @see Node#inspect
def inspect
"(#{to_sass})"
end
protected
# @see Node#_perform
def _perform(environment)
list = Sass::Script::List.new(
value.map {|e| e.perform(environment)},
separator)
list.options = self.options
list
end
private
def sep_str(opts = self.options)
return ' ' if separator == :space
return ',' if opts && opts[:style] == :compressed
return ', '
end
end
end
|