class Sass::Selector::AbstractSequence

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_a` method that returns an array of strings and script nodes.

Attributes

filename[R]

The name of the file in which this selector was declared.

@return [String, nil]

line[R]

The line of the Sass template on which this selector was declared.

@return [Fixnum]

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source

Checks equality between this and another object.

Subclasses should define `#_eql?` rather than overriding this method, which handles checking class equality and hash equality.

@param other [Object] The object to test equality against @return [Boolean] Whether or not this is equal to `other`

# File lib/sass/selector/abstract_sequence.rb, line 57
def eql?(other)
  other.class == self.class && other.hash == self.hash && _eql?(other)
end
Also aliased as: ==
filename=(filename) click to toggle source

Sets 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). This also sets the filename for all child selectors.

@param filename [String, nil] @return [String, nil]

# File lib/sass/selector/abstract_sequence.rb, line 35
def filename=(filename)
  members.each {|m| m.filename = filename}
  @filename = filename
end
has_placeholder?() click to toggle source

Whether or not this selector sequence contains a placeholder selector. Checks recursively.

# File lib/sass/selector/abstract_sequence.rb, line 64
def has_placeholder?
  @has_placeholder ||=
    members.any? {|m| m.is_a?(AbstractSequence) ? m.has_placeholder? : m.is_a?(Placeholder)}
end
hash() click to toggle source

Returns a hash code for this sequence.

Subclasses should define `#_hash` rather than overriding this method, which automatically handles memoizing the result.

@return [Fixnum]

# File lib/sass/selector/abstract_sequence.rb, line 46
def hash
  @_hash ||= _hash
end
line=(line) click to toggle source

Sets the line of the Sass template on which this selector was declared. This also sets the line for all child selectors.

@param line [Fixnum] @return [Fixnum]

# File lib/sass/selector/abstract_sequence.rb, line 24
def line=(line)
  members.each {|m| m.line = line}
  @line = line
end
specificity() click to toggle source

Returns the specificity of the selector as an integer. The base is given by {Sass::Selector::SPECIFICITY_BASE}.

@return [Fixnum]

# File lib/sass/selector/abstract_sequence.rb, line 81
def specificity
  _specificity(members)
end
to_s() click to toggle source

Converts the selector into a string. This is the standard selector string, along with any SassScript interpolation that may exist.

@return [String]

# File lib/sass/selector/abstract_sequence.rb, line 73
def to_s
  to_a.map {|e| e.is_a?(Sass::Script::Node) ? "\#{#{e.to_sass}}" : e}.join
end

Protected Instance Methods

_specificity(arr) click to toggle source
# File lib/sass/selector/abstract_sequence.rb, line 87
def _specificity(arr)
  spec = 0
  arr.map {|m| spec += m.is_a?(String) ? 0 : m.specificity}
  spec
end