Class: RSAC::Conditions::CombinatorCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb

Instance Attribute Summary collapse

Attributes inherited from Condition

#condition_type

Instance Method Summary collapse

Methods inherited from Condition

#eql?

Constructor Details

#initialize(first, second) ⇒ CombinatorCondition

Returns a new instance of CombinatorCondition.



8
9
10
11
12
13
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 8

def initialize(first, second)
  super(:SAC_AND_CONDITION)

  @first_condition = first
  @second_condition = second
end

Instance Attribute Details

#first_conditionObject Also known as: first

Returns the value of attribute first_condition.



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

def first_condition
  @first_condition
end

#second_conditionObject Also known as: second

Returns the value of attribute second_condition.



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

def second_condition
  @second_condition
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 27

def ==(other)
  super && first == other.first && second == other.second
end

#hashObject



31
32
33
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 31

def hash
  [first, second].hash
end

#specificityObject



23
24
25
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 23

def specificity
  first.specificity.zip(second.specificity).map { |x,y| x + y }
end

#to_cssObject



15
16
17
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 15

def to_css
  "#{first.to_css}#{second.to_css}"
end

#to_xpathObject



19
20
21
# File 'lib/antisamy/csspool/rsac/sac/conditions/combinator_condition.rb', line 19

def to_xpath
  "#{first.to_xpath}#{second.to_xpath}"
end