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