Class: Sass::Selector::Pseudo
Overview
A pseudoclass (e.g. :visited
) or pseudoelement (e.g. ::first-line
) selector.
It can have arguments (e.g. :nth-child(2n+1)
).
Instance Attribute Summary collapse
-
#arg ⇒ Array<String, Sass::Script::Node>?
readonly
The argument to the selector, or
nil
if no argument was given. -
#name ⇒ Array<String, Sass::Script::Node>
readonly
The name of the selector.
-
#type ⇒ Symbol
readonly
The type of the selector.
Attributes inherited from Simple
Instance Method Summary collapse
-
#initialize(type, name, arg) ⇒ Pseudo
constructor
A new instance of Pseudo.
- #to_a
-
#unify(sels)
Returns
nil
if this is a pseudoclass selector andsels
contains a pseudoclass selector different than this one.
Methods inherited from Simple
#eql?, #hash, #inspect, #unify_namespaces
Constructor Details
#initialize(type, name, arg) ⇒ Pseudo
Returns a new instance of Pseudo.
309 310 311 312 313 |
# File 'lib/sass/selector.rb', line 309
def initialize(type, name, arg)
@type = type
@name = name
@arg = arg
end
|
Instance Attribute Details
#arg ⇒ Array<String, Sass::Script::Node>? (readonly)
The argument to the selector,
or nil
if no argument was given.
This may include SassScript nodes that will be run during resolution. Note that this should not include SassScript nodes after resolution has taken place.
303 304 305 |
# File 'lib/sass/selector.rb', line 303
def arg
@arg
end
|
#name ⇒ Array<String, Sass::Script::Node> (readonly)
The name of the selector.
293 294 295 |
# File 'lib/sass/selector.rb', line 293
def name
@name
end
|
#type ⇒ Symbol (readonly)
The type of the selector.
:class
if this is a pseudoclass selector,
:element
if it's a pseudoelement.
288 289 290 |
# File 'lib/sass/selector.rb', line 288
def type
@type
end
|
Instance Method Details
#to_a
316 317 318 319 320 |
# File 'lib/sass/selector.rb', line 316
def to_a
res = [@type == :class ? ":" : "::"] + @name
(res << "(").concat(Sass::Util.strip_string_array(@arg)) << ")" if @arg
res
end
|
#unify(sels)
Returns nil
if this is a pseudoclass selector
and sels
contains a pseudoclass selector different than this one.
326 327 328 329 330 331 332 |
# File 'lib/sass/selector.rb', line 326
def unify(sels)
return if type == :element && sels.any? do |sel|
sel.is_a?(Pseudo) && sel.type == :element &&
(sel.name != self.name || sel.arg != self.arg)
end
super
end
|