Class: Sass::Selector::Simple
- Inherits:
-
Object
- Object
- Sass::Selector::Simple
- Defined in:
- .ruby-sass/lib/sass/selector/simple.rb
Overview
The abstract superclass for simple selectors (that is, those that don't compose multiple selectors).
Instance Attribute Summary (collapse)
-
#filename ⇒ String?
The name of the file in which this selector was declared, or `nil` if it was not declared in a file (e.g. on stdin).
-
#line ⇒ Integer
The line of the Sass template on which this selector was declared.
Instance Method Summary (collapse)
-
#eql?(other) ⇒ Boolean
(also: #==)
Checks equality between this and another object.
-
#hash ⇒ Integer
Returns a hash code for this selector object.
- #inspect ⇒ String
-
#to_s(opts = {}) ⇒ String
Returns the selector string.
-
#unify(sels) ⇒ Array<Simple>?
Unifies this selector with a SimpleSequence's members array, returning another `SimpleSequence` members array that matches both this selector and the input selector.
-
#unique? ⇒ Boolean
Whether only one instance of this simple selector is allowed in a given complex selector.
Instance Attribute Details
#filename ⇒ String?
The name of the file in which this selector was declared, or `nil` if it was not declared in a file (e.g. on stdin).
15 16 17 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 15 def filename @filename end |
#line ⇒ Integer
The line of the Sass template on which this selector was declared.
9 10 11 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 9 def line @line end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Checks equality between this and another object.
By default, this is based on the value of #to_a, so if that contains information irrelevant to the identity of the selector, this should be overridden.
60 61 62 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 60 def eql?(other) other.class == self.class && other.hash == hash && other.equality_key == equality_key end |
#hash ⇒ Integer
Returns a hash code for this selector object.
By default, this is based on the value of #to_a, so if that contains information irrelevant to the identity of the selector, this should be overridden.
48 49 50 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 48 def hash @_hash ||= equality_key.hash end |
#inspect ⇒ String
28 29 30 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 28 def inspect to_s end |
#to_s(opts = {}) ⇒ String
Returns the selector string.
37 38 39 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 37 def to_s(opts = {}) Sass::Util.abstract(self) end |
#unify(sels) ⇒ Array<Simple>?
Unifies this selector with a Sass::Selector::SimpleSequence's members array, returning another `SimpleSequence` members array that matches both this selector and the input selector.
By default, this just appends this selector to the end of the array (or returns the original array if this selector already exists in it).
82 83 84 85 86 87 88 89 90 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 82 def unify(sels) return sels.first.unify([self]) if sels.length == 1 && sels.first.is_a?(Universal) return sels if sels.any? {|sel2| eql?(sel2)} if !is_a?(Pseudo) || (sels.last.is_a?(Pseudo) && sels.last.type == :element) _, i = sels.each_with_index.find {|sel, _| sel.is_a?(Pseudo)} end return sels + [self] unless i sels[0...i] + [self] + sels[i..-1] end |
#unique? ⇒ Boolean
Whether only one instance of this simple selector is allowed in a given complex selector.
21 22 23 |
# File '.ruby-sass/lib/sass/selector/simple.rb', line 21 def unique? false end |