class Roadie::Selector
anywhere a String is expected.
Selectors can be coerced into Strings, so they should be transparent to use
questions about them.
This class can also calculate specificity for the selector and answer a few
represented as two instances of this class.
“Selectors” such as “strong, em” are actually two selectors and should be
p:nth-of-child(4n+1) .important a img
input::placeholder
a:hover
body
A selector is a domain object for a CSS selector, such as:
@api private
def ==(other)
{Selector}s are equal to other {Selector}s if, and only if, their string
def ==(other) if other.is_a?(self.class) other.selector == selector else super end end
def at_rule?
def at_rule? selector[0, 1] == '@' end
def initialize(selector, specificity = nil)
def initialize(selector, specificity = nil) @selector = selector.to_s.strip @specificity = specificity end
def inlinable?
(like +::placeholder+, +::before+) or a pseudo function (like +:active+).
It's impossible to inline properties that applies to a pseudo element
Returns whenever or not a selector can be inlined.
def inlinable? !(pseudo_element? || at_rule? || pseudo_function?) end
def inspect() selector.inspect end
def inspect() selector.inspect end
def pseudo_element?
def pseudo_element? selector.include? '::' end
def pseudo_function?
def pseudo_function? BAD_PSEUDO_FUNCTIONS.any? { |bad| selector.include?(bad) } end
def specificity
def specificity @specificity ||= CssParser.calculate_specificity selector end
def to_s() selector end
def to_s() selector end
def to_str() to_s end
def to_str() to_s end