Class: CSSPool::Selector
Instance Attribute Summary collapse
-
#parse_location ⇒ Object
Returns the value of attribute parse_location.
-
#rule_set ⇒ Object
Returns the value of attribute rule_set.
-
#simple_selectors ⇒ Object
Returns the value of attribute simple_selectors.
Instance Method Summary collapse
- #declarations ⇒ Object
-
#initialize(simple_selectors = [], parse_location = {}) ⇒ Selector
constructor
A new instance of Selector.
- #specificity ⇒ Object
Methods inherited from Node
#==, #accept, #children, #each, #hash, #to_css, #to_minified_css
Constructor Details
#initialize(simple_selectors = [], parse_location = {}) ⇒ Selector
Returns a new instance of Selector.
7 8 9 10 11 |
# File 'lib/csspool/selector.rb', line 7 def initialize simple_selectors = [], parse_location = {} @simple_selectors = simple_selectors @parse_location = parse_location @rule_set = nil end |
Instance Attribute Details
#parse_location ⇒ Object
Returns the value of attribute parse_location.
4 5 6 |
# File 'lib/csspool/selector.rb', line 4 def parse_location @parse_location end |
#rule_set ⇒ Object
Returns the value of attribute rule_set.
5 6 7 |
# File 'lib/csspool/selector.rb', line 5 def rule_set @rule_set end |
#simple_selectors ⇒ Object
Returns the value of attribute simple_selectors.
3 4 5 |
# File 'lib/csspool/selector.rb', line 3 def simple_selectors @simple_selectors end |
Instance Method Details
#declarations ⇒ Object
13 14 15 |
# File 'lib/csspool/selector.rb', line 13 def declarations @rule_set.declarations end |
#specificity ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/csspool/selector.rb', line 17 def specificity a = b = c = 0 simple_selectors.each do |s| if !s.name.nil? c += 1 end s.additional_selectors.each do |additional_selector| if Selectors::Id === additional_selector a += 1 elsif Selectors::PseudoElement === additional_selector c += 1 else b += 1 end end end [a, b, c] end |