Class: RSAC::Selectors::ElementSelector

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

Instance Attribute Summary collapse

Attributes inherited from Selector

#selector_type

Instance Method Summary collapse

Methods inherited from Selector

#eql?

Constructor Details

#initialize(name) ⇒ ElementSelector

Returns a new instance of ElementSelector.



7
8
9
10
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 7

def initialize(name)
  super(:SAC_ELEMENT_NODE_SELECTOR)
  @local_name = name
end

Instance Attribute Details

#local_nameObject (readonly) Also known as: name

Returns the value of attribute local_name.



4
5
6
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 4

def local_name
  @local_name
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 26

def ==(other)
  super && name == other.name
end

#hashObject



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

def hash
  name.hash
end

#specificityObject



22
23
24
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 22

def specificity
  [0, 0, 0, 1]
end

#to_cssObject



12
13
14
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 12

def to_css
  local_name
end

#to_xpath(prefix = true) ⇒ Object



16
17
18
19
20
# File 'lib/antisamy/csspool/rsac/sac/selectors/element_selector.rb', line 16

def to_xpath(prefix=true)
  atoms = [local_name]
  atoms.unshift("//") if prefix
  atoms.join
end