Class: CSSPool::Selector
Constant Summary collapse
- COMBINATORS =
[nil, ' ', ' + ', ' > ']
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 included from Visitable
#==, #accept, #children, #each, #hash, #to_css
Constructor Details
#initialize(simple_selectors = [], parse_location = {}) ⇒ Selector
Returns a new instance of Selector.
10 11 12 13 14 |
# File 'lib/csspool/selector.rb', line 10 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
16 17 18 |
# File 'lib/csspool/selector.rb', line 16 def declarations @rule_set.declarations end |
#specificity ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/csspool/selector.rb', line 20 def specificity a = b = c = 0 simple_selectors.each do |s| c += 1 s.additional_selectors.each do |additional_selector| if Selectors::Id === additional_selector a += 1 else b += 1 end end end [a, b, c] end |