Sha256: 2e37c2670f6a138518f448d432df55585c9b9a9775676843f2c9d9c0d57b6288
Contents?: true
Size: 1021 Bytes
Versions: 2
Compression:
Stored size: 1021 Bytes
Contents
module Roadie class Selector def initialize(selector) @selector = selector.to_s.strip end def specificity @specificity ||= CssParser.calculate_specificity selector end def inlinable? !(pseudo_element? || at_rule? || pseudo_function?) end def to_s selector end def to_str() to_s end def inspect() selector.inspect end def ==(other) if other.is_a?(self.class) other.selector == selector else super end end protected attr_reader :selector private BAD_PSEUDO_FUNCTIONS = %w[:active :focus :hover :link :target :visited :-ms-input-placeholder :-moz-placeholder :before :after].freeze def pseudo_element? selector.include? '::' end def at_rule? selector[0, 1] == '@' end def pseudo_function? BAD_PSEUDO_FUNCTIONS.any? { |bad| selector.include?(bad) } end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
md-roadie-2.4.2.md.1 | lib/roadie/selector.rb |
roadie-2.4.2 | lib/roadie/selector.rb |