module XPath::DSL

Constants

AXES
METHODS
OPERATORS

Public Instance Methods

+(*expressions)
Alias for: union
[](expression)
Alias for: where
anywhere(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 19
def anywhere(*expressions)
  Expression.new(:anywhere, expressions)
end
attr(expression) click to toggle source
# File lib/xpath/dsl.rb, line 23
def attr(expression)
  Expression.new(:attribute, current, expression)
end
axis(name, *element_names) click to toggle source
# File lib/xpath/dsl.rb, line 15
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 56
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 11
def child(*expressions)
  Expression.new(:child, current, expressions)
end
contains_word(word) click to toggle source
# File lib/xpath/dsl.rb, line 145
def contains_word(word)
  function(:concat, " ", current.normalize_space, " ").contains(" #{word} ")
end
css(selector) click to toggle source
# File lib/xpath/dsl.rb, line 31
def css(selector)
  Expression.new(:css, current, Literal.new(selector))
end
current() click to toggle source
# File lib/xpath/dsl.rb, line 3
def current
  Expression.new(:this_node)
end
descendant(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 7
def descendant(*expressions)
  Expression.new(:descendant, current, expressions)
end
ends_with(suffix) click to toggle source
# File lib/xpath/dsl.rb, line 141
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 35
def function(name, *arguments)
  Expression.new(:function, name, *arguments)
end
is(expression) click to toggle source
# File lib/xpath/dsl.rb, line 52
def is(expression)
  Expression.new(:is, current, expression)
end
last() click to toggle source
# File lib/xpath/dsl.rb, line 65
def last
  function(:last)
end
method(name, *arguments) click to toggle source
# File lib/xpath/dsl.rb, line 39
def method(name, *arguments)
  Expression.new(:function, name, current, *arguments)
end
next_sibling(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 157
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 149
def one_of(*expressions)
  expressions.map do |e|
    current.equals(e)
  end.reduce do |a, b|
    a.or(b)
  end
end
position() click to toggle source
# File lib/xpath/dsl.rb, line 69
def position
  function(:position)
end
previous_sibling(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 161
def previous_sibling(*expressions)
  axis(:"preceding-sibling")[1].axis(:self, *expressions)
end
qname() click to toggle source
# File lib/xpath/dsl.rb, line 93
def qname
  method(:name)
end
text() click to toggle source
# File lib/xpath/dsl.rb, line 27
def text
  Expression.new(:text, current)
end
union(*expressions) click to toggle source
# File lib/xpath/dsl.rb, line 60
def union(*expressions)
  Union.new(*[self, expressions].flatten)
end
Also aliased as: +
where(expression) click to toggle source
# File lib/xpath/dsl.rb, line 43
def where(expression)
  if expression
    Expression.new(:where, current, expression)
  else
    current
  end
end
Also aliased as: []