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