Class: RSAC::Selectors::SiblingSelector

Inherits:
SimpleSelector show all
Defined in:
lib/antisamy/csspool/rsac/sac/selectors/sibling_selector.rb

Instance Attribute Summary collapse

Attributes inherited from Selector

#selector_type

Instance Method Summary collapse

Methods inherited from Selector

#eql?

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

#selectorObject

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_selectorObject 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

#hashObject



30
31
32
# File 'lib/antisamy/csspool/rsac/sac/selectors/sibling_selector.rb', line 30

def hash
  [selector, sibling].hash
end

#specificityObject



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_cssObject



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