Class: Capybara::Selector::XPathBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/selector/builders/xpath_builder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression) ⇒ XPathBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of XPathBuilder.



9
10
11
# File 'lib/capybara/selector/builders/xpath_builder.rb', line 9

def initialize(expression)
  @expression = expression || ''
end

Instance Attribute Details

#expressionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/capybara/selector/builders/xpath_builder.rb', line 13

def expression
  @expression
end

Instance Method Details

#add_attribute_conditions(**conditions) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/capybara/selector/builders/xpath_builder.rb', line 15

def add_attribute_conditions(**conditions)
  @expression = conditions.inject(expression) do |xp, (name, value)|
    conditions = name == :class ? class_conditions(value) : attribute_conditions(name => value)
    return xp if conditions.nil?

    if xp.is_a? XPath::Expression
      xp[conditions]
    else
      "(#{xp})[#{conditions}]"
    end
  end
end