module XPath::DSL

Constants

AXES
LOWERCASE_LETTERS
METHODS
OPERATORS
UPPERCASE_LETTERS

Public Instance Methods

+(*expressions)
Alias for: union
[](expression)
Alias for: where
anywhere(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 21
def anywhere(*expressions)
  Expression.new(:anywhere, expressions)
end
attr(expression) click to toggle source
# File lib/xpath/dsl.rb, line 25
def attr(expression)
  Expression.new(:attribute, current, expression)
end
axis(name, *element_names) click to toggle source
# File lib/xpath/dsl.rb, line 17
def axis(name, *element_names)
  Expression.new(:axis, current, name, element_names)
end
binary_operator(name, rhs) click to toggle source
# File lib/xpath/dsl.rb, line 58
def binary_operator(name, rhs)
  Expression.new(:binary_operator, name, current, rhs)
end
child(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 13
def child(*expressions)
  Expression.new(:child, current, expressions)
end
contains_word(word) click to toggle source
# File lib/xpath/dsl.rb, line 147
def contains_word(word)
  function(:concat, ' ', current.normalize_space, ' ').contains(" #{word} ")
end
css(selector) click to toggle source
# File lib/xpath/dsl.rb, line 33
def css(selector)
  Expression.new(:css, current, Literal.new(selector))
end
current() click to toggle source
# File lib/xpath/dsl.rb, line 5
def current
  Expression.new(:this_node)
end
descendant(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 9
def descendant(*expressions)
  Expression.new(:descendant, current, expressions)
end
ends_with(suffix) click to toggle source
# File lib/xpath/dsl.rb, line 143
def ends_with(suffix)
  function(:substring, current, function(:'string-length', current).minus(function(:'string-length', suffix)).plus(1)) == suffix
end
function(name, *arguments) click to toggle source
# File lib/xpath/dsl.rb, line 37
def function(name, *arguments)
  Expression.new(:function, name, *arguments)
end
is(expression) click to toggle source
# File lib/xpath/dsl.rb, line 54
def is(expression)
  Expression.new(:is, current, expression)
end
last() click to toggle source
# File lib/xpath/dsl.rb, line 67
def last
  function(:last)
end
lowercase() click to toggle source
# File lib/xpath/dsl.rb, line 154
def lowercase
  method(:translate, UPPERCASE_LETTERS, LOWERCASE_LETTERS)
end
method(name, *arguments) click to toggle source
# File lib/xpath/dsl.rb, line 41
def method(name, *arguments)
  Expression.new(:function, name, current, *arguments)
end
next_sibling(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 166
def next_sibling(*expressions)
  axis(:"following-sibling")[1].axis(:self, *expressions)
end
one_of(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 162
def one_of(*expressions)
  expressions.map { |e| current.equals(e) }.reduce(:or)
end
position() click to toggle source
# File lib/xpath/dsl.rb, line 71
def position
  function(:position)
end
previous_sibling(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 170
def previous_sibling(*expressions)
  axis(:"preceding-sibling")[1].axis(:self, *expressions)
end
qname() click to toggle source
# File lib/xpath/dsl.rb, line 95
def qname
  method(:name)
end
text() click to toggle source
# File lib/xpath/dsl.rb, line 29
def text
  Expression.new(:text, current)
end
union(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 62
def union(*expressions)
  Union.new(*[self, expressions].flatten)
end
Also aliased as: +
uppercase() click to toggle source
# File lib/xpath/dsl.rb, line 158
def uppercase
  method(:translate, LOWERCASE_LETTERS, UPPERCASE_LETTERS)
end
where(expression) click to toggle source
# File lib/xpath/dsl.rb, line 45
def where(expression)
  if expression
    Expression.new(:where, current, expression)
  else
    current
  end
end
Also aliased as: []