Class: CSS::SAC::Conditions::CombinatorCondition

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

Instance Attribute Summary collapse

Attributes inherited from Condition

#condition_type

Instance Method Summary collapse

Methods inherited from Condition

#=~, #eql?

Methods included from Visitable

#accept

Constructor Details

#initialize(first, second) ⇒ CombinatorCondition

Returns a new instance of CombinatorCondition.



11
12
13
14
15
16
# File 'lib/css/sac/conditions/combinator_condition.rb', line 11

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.



7
8
9
# File 'lib/css/sac/conditions/combinator_condition.rb', line 7

def first_condition
  @first_condition
end

#second_conditionObject Also known as: second

Returns the value of attribute second_condition.



7
8
9
# File 'lib/css/sac/conditions/combinator_condition.rb', line 7

def second_condition
  @second_condition
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/css/sac/conditions/combinator_condition.rb', line 30

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

#hashObject



34
35
36
# File 'lib/css/sac/conditions/combinator_condition.rb', line 34

def hash
  [first, second].hash
end

#specificityObject



26
27
28
# File 'lib/css/sac/conditions/combinator_condition.rb', line 26

def specificity
  first.specificity + second.specificity
end

#to_cssObject



18
19
20
# File 'lib/css/sac/conditions/combinator_condition.rb', line 18

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

#to_xpathObject



22
23
24
# File 'lib/css/sac/conditions/combinator_condition.rb', line 22

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