### Home Classes Methods

### In Files

- lib/sass/selector/simple.rb

### Parent

Object

### Methods

- #==
- #eql?
- #equality_key
- #hash
- #inspect
- #to_s
- #unify
- #unify_namespaces

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Script::Value::String
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Selector::Simple

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

### Attributes

filename[RW]

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).

@return [String, nil]

line[RW]

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

@return [Fixnum]

### Public Instance Methods

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

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.

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

    # File lib/sass/selector/simple.rb, line 50
    def eql?(other)
      other.class == self.class && other.hash == hash && other.equality_key == equality_key
    end

Also aliased as: ==
hash() click to toggle source

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.

@return [Fixnum]

    # File lib/sass/selector/simple.rb, line 38
    def hash
      @_hash ||= equality_key.hash
    end

inspect() click to toggle source

@see to_s

@return [String]

    # File lib/sass/selector/simple.rb, line 20
    def inspect
      to_s
    end

to_s() click to toggle source

Returns the selector string.

@return [String]

    # File lib/sass/selector/simple.rb, line 27
    def to_s
      Sass::Util.abstract(self)
    end

unify(sels) click to toggle source

Unifies this selector with a {SimpleSequence}‘s {SimpleSequence#members 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).

@param sels [Array<Simple>] A {SimpleSequence}‘s {SimpleSequence#members members array} @return [Array<Simple>, nil] A {SimpleSequence} {SimpleSequence#members members array}

    matching both `sels` and this selector,
    or `nil` if this is impossible (e.g. unifying `#foo` and `#bar`)

@raise [Sass::SyntaxError] If this selector cannot be unified.

    This will only ever occur when a dynamic selector,
    such as {Parent} or {Interpolation}, is used in unification.
    Since these selectors should be resolved
    by the time extension and unification happen,
    this exception will only ever be raised as a result of programmer error

    # File lib/sass/selector/simple.rb, line 72
    def unify(sels)
      return sels if sels.any? {|sel2| eql?(sel2)}
      sels_with_ix = Sass::Util.enum_with_index(sels)
      if !is_a?(Pseudo) || (sels.last.is_a?(Pseudo) && sels.last.type == :element)
        _, i = sels_with_ix.find {|sel, _| sel.is_a?(Pseudo)}
      end
      return sels + [self] unless i
      sels[0...i] + [self] + sels[i..-1]
    end

### Protected Instance Methods

equality_key() click to toggle source

Returns the key used for testing whether selectors are equal.

This is a cached version of {#to_s}.

@return [String]

    # File lib/sass/selector/simple.rb, line 89
    def equality_key
      @equality_key ||= to_s
    end

unify_namespaces(ns1, ns2) click to toggle source

Unifies two namespaces, returning a namespace that works for both of them if possible.

@param ns1 [String, nil] The first namespace.

    `nil` means none specified, e.g. `foo`.
    The empty string means no namespace specified, e.g. `|foo`.
    `"*"` means any namespace is allowed, e.g. `*|foo`.

@param ns2 [String, nil] The second namespace. See `ns1`. @return [Array(String or nil, Boolean)]

    The first value is the unified namespace, or `nil` for no namespace.
    The second value is whether or not a namespace that works for both inputs
    could be found at all.
    If the second value is `false`, the first should be ignored.

    # File lib/sass/selector/simple.rb, line 106
    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 == '*'
      [ns1 || ns2, true]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.