Class: RSAC::Selectors::DescendantSelector
- Inherits:
-
SimpleSelector
- Object
- Selector
- SimpleSelector
- RSAC::Selectors::DescendantSelector
- Defined in:
- lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb
Instance Attribute Summary collapse
-
#ancestor_selector ⇒ Object
(also: #ancestor)
Returns the value of attribute ancestor_selector.
-
#simple_selector ⇒ Object
(also: #selector)
Returns the value of attribute simple_selector.
Attributes inherited from Selector
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(ancestor, selector) ⇒ DescendantSelector
constructor
A new instance of DescendantSelector.
- #specificity ⇒ Object
- #to_css ⇒ Object
- #to_xpath(prefix = true) ⇒ Object
Methods inherited from Selector
Constructor Details
#initialize(ancestor, selector) ⇒ DescendantSelector
Returns a new instance of DescendantSelector.
8 9 10 11 12 13 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 8 def initialize(ancestor, selector) super(:SAC_DESCENDANT_SELECTOR) @ancestor_selector = ancestor @simple_selector = selector end |
Instance Attribute Details
#ancestor_selector ⇒ Object Also known as: ancestor
Returns the value of attribute ancestor_selector.
4 5 6 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 4 def ancestor_selector @ancestor_selector end |
#simple_selector ⇒ Object Also known as: selector
Returns the value of attribute simple_selector.
4 5 6 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 4 def simple_selector @simple_selector end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 27 def ==(other) super && selector == other.selector && ancestor == other.ancestor end |
#hash ⇒ Object
31 32 33 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 31 def hash [selector, ancestor].hash end |
#specificity ⇒ Object
23 24 25 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 23 def specificity ancestor.specificity.zip(selector.specificity).map { |x,y| x + y } end |
#to_css ⇒ Object
15 16 17 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 15 def to_css "#{ancestor.to_css} #{selector.to_css}" end |
#to_xpath(prefix = true) ⇒ Object
19 20 21 |
# File 'lib/antisamy/csspool/rsac/sac/selectors/descendant_selector.rb', line 19 def to_xpath(prefix=true) "#{ancestor.to_xpath(prefix)}//#{selector.to_xpath(false)}" end |