Class: Sass::Selector::AbstractSequence
- Inherits:
- Object
- Object
- Sass::Selector::AbstractSequence
- Defined in:
- /Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb
Overview
The abstract parent class of the various selector sequence classes.
All subclasses should implement a members
method that returns an array of object that respond to #line=
and #filename=
, as well as a to_s
method that returns the string representation of the selector.
Direct Known Subclasses
Instance Attribute Summary (collapse)
- - (String?) filename
The name of the file in which this selector was declared.
- - (Fixnum) line
The line of the Sass template on which this selector was declared.
Instance Method Summary (collapse)
- - _specificity(arr) protected
- - (Boolean) eql?(other) (also: #==)
Checks equality between this and another object.
- - (Boolean) has_placeholder?
Whether or not this selector sequence contains a placeholder selector.
- - (Fixnum) hash
Returns a hash code for this sequence.
- - (Fixnum, Range) specificity
Returns the specificity of the selector.
- - (String) to_s(opts = {})
Returns the selector string.
Instance Attribute Details
- (String?) filename
The name of the file in which this selector was declared.
17 18 19 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 17
def filename
@filename
end |
- (Fixnum) line
The line of the Sass template on which this selector was declared.
12 13 14 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 12
def line
@line
end |
Instance Method Details
- _specificity(arr) (protected)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 93
def _specificity(arr)
min = 0
max = 0
arr.each do |m|
next if m.is_a?(String)
spec = m.specificity
if spec.is_a?(Range)
min += spec.begin
max += spec.end
else
min += spec
max += spec
end
end
min == max ? min : (min..max)
end |
- (Boolean) eql?(other) Also known as: ==
Checks equality between this and another object.
Subclasses should define #_eql?
rather than overriding this method, which handles checking class equality and hash equality.
57 58 59 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 57
def eql?(other)
other.class == self.class && other.hash == hash && _eql?(other)
end |
- (Boolean) has_placeholder?
Whether or not this selector sequence contains a placeholder selector. Checks recursively.
64 65 66 67 68 69 70 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 64
def has_placeholder?
@has_placeholder ||= members.any? do |m|
next m.has_placeholder? if m.is_a?(AbstractSequence)
next m.selector && m.selector.has_placeholder? if m.is_a?(Pseudo)
m.is_a?(Placeholder)
end
end |
- (Fixnum) hash
Returns a hash code for this sequence.
Subclasses should define #_hash
rather than overriding this method, which automatically handles memoizing the result.
46 47 48 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 46
def hash
@_hash ||= _hash
end |
- (Fixnum, Range) specificity
Returns the specificity of the selector.
The base is given by SPECIFICITY_BASE. This can be a number or a range representing possible specificities.
87 88 89 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 87
def specificity
_specificity(members)
end |
- (String) to_s(opts = {})
Returns the selector string.
77 78 79 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb', line 77
def to_s(opts = {})
Sass::Util.abstract(self)
end |