class Sass::Selector::Simple

(that is, those that don’t compose multiple selectors).
The abstract superclass for simple selectors

def eql?(other)

Returns:
  • (Boolean) - Whether or not this is equal to `other`

Parameters:
  • other (Object) -- The object to test equality against
def eql?(other)
  other.class == self.class && other.hash == self.hash && other.to_a.eql?(to_a)
end

def hash

Returns:
  • (Fixnum) -
def hash
  @_hash ||= to_a.hash
end

def inspect

Returns:
  • (String) -
def inspect
  to_a.map {|e| e.is_a?(Sass::Script::Node) ? "\#{#{e.to_sass}}" : e}.join
end

def to_a

Returns:
  • (Array) -
def to_a
  raise NotImplementedError.new("All subclasses of Sass::Selector::Simple must override #to_a.")
end

def unify(sels)

Raises:
  • (Sass::SyntaxError) - If this selector cannot be unified.

Returns:
  • (Array, nil) - A {SimpleSequence} {SimpleSequence#members members array}

Parameters:
  • sels (Array) -- A {SimpleSequence}'s {SimpleSequence#members members array}
def unify(sels)
  return sels if sels.any? {|sel2| eql?(sel2)}
  sels_with_ix = Haml::Util.enum_with_index(sels)
  _, i =
    if self.is_a?(Pseudo) || self.is_a?(Negation)
      sels_with_ix.find {|sel, _| sel.is_a?(Pseudo) && sels.last.type == :element}
    else
      sels_with_ix.find {|sel, _| sel.is_a?(Pseudo) || sel.is_a?(Negation)}
    end
  return sels + [self] unless i
  return sels[0...i] + [self] + sels[i..-1]
end

def unify_namespaces(ns1, ns2)

Returns:
  • (Array(String or nil, Boolean)) -

Parameters:
  • ns2 (String, nil) -- The second namespace. See `ns1`.
  • ns1 (String, nil) -- The first namespace.
def unify_namespaces(ns1, ns2)
  return nil, false unless ns1 == ns2 || ns1.nil? || ns1 == ['*'] || ns2.nil? || ns2 == ['*']
  return ns2, true if ns1 == ['*']
  return ns1, true if ns2 == ['*']
  return ns1 || ns2, true
end