module XPath::DSL
Constants
- AXES
- LOWERCASE_LETTERS
- METHODS
- OPERATORS
- UPPERCASE_LETTERS
Public Instance Methods
anywhere(*expressions)
click to toggle source
# File lib/xpath/dsl.rb, line 20 def anywhere(*expressions) Expression.new(:anywhere, expressions) end
attr(expression)
click to toggle source
# File lib/xpath/dsl.rb, line 24 def attr(expression) Expression.new(:attribute, current, expression) end
axis(name, *element_names)
click to toggle source
# File lib/xpath/dsl.rb, line 16 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 57 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 12 def child(*expressions) Expression.new(:child, current, expressions) end
contains_word(word)
click to toggle source
# File lib/xpath/dsl.rb, line 146 def contains_word(word) function(:concat, ' ', current.normalize_space, ' ').contains(" #{word} ") end
css(selector)
click to toggle source
# File lib/xpath/dsl.rb, line 32 def css(selector) Expression.new(:css, current, Literal.new(selector)) end
current()
click to toggle source
# File lib/xpath/dsl.rb, line 4 def current Expression.new(:this_node) end
descendant(*expressions)
click to toggle source
# File lib/xpath/dsl.rb, line 8 def descendant(*expressions) Expression.new(:descendant, current, expressions) end
ends_with(suffix)
click to toggle source
# File lib/xpath/dsl.rb, line 142 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 36 def function(name, *arguments) Expression.new(:function, name, *arguments) end
is(expression)
click to toggle source
# File lib/xpath/dsl.rb, line 53 def is(expression) Expression.new(:is, current, expression) end
last()
click to toggle source
# File lib/xpath/dsl.rb, line 66 def last function(:last) end
lowercase()
click to toggle source
# File lib/xpath/dsl.rb, line 153 def lowercase method(:translate, UPPERCASE_LETTERS, LOWERCASE_LETTERS) end
method(name, *arguments)
click to toggle source
# File lib/xpath/dsl.rb, line 40 def method(name, *arguments) Expression.new(:function, name, current, *arguments) end
next_sibling(*expressions)
click to toggle source
# File lib/xpath/dsl.rb, line 165 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 161 def one_of(*expressions) expressions.map { |e| current.equals(e) }.reduce(:or) end
position()
click to toggle source
# File lib/xpath/dsl.rb, line 70 def position function(:position) end
previous_sibling(*expressions)
click to toggle source
# File lib/xpath/dsl.rb, line 169 def previous_sibling(*expressions) axis(:"preceding-sibling")[1].axis(:self, *expressions) end
qname()
click to toggle source
# File lib/xpath/dsl.rb, line 94 def qname method(:name) end
text()
click to toggle source
# File lib/xpath/dsl.rb, line 28 def text Expression.new(:text, current) end
union(*expressions)
click to toggle source
# File lib/xpath/dsl.rb, line 61 def union(*expressions) Union.new(*[self, expressions].flatten) end
Also aliased as: +
uppercase()
click to toggle source
# File lib/xpath/dsl.rb, line 157 def uppercase method(:translate, LOWERCASE_LETTERS, UPPERCASE_LETTERS) end
where(expression)
click to toggle source
# File lib/xpath/dsl.rb, line 44 def where(expression) if expression Expression.new(:where, current, expression) else current end end
Also aliased as: []