Class: XPath::Expression
- Inherits:
-
Object
show all
- Includes:
- XPath
- Defined in:
- lib/xpath/expression.rb
Defined Under Namespace
Classes: And, Anywhere, Applied, Attribute, Binary, CSS, Child, Contains, Descendant, Equality, Inverse, Is, Literal, Multiple, Name, NextSibling, NormalizedSpace, OneOf, Or, Self, StringFunction, StringLiteral, Text, Unary, Variable, Where
Constant Summary
Constants included
from XPath
VERSION
Instance Method Summary
collapse
Methods included from XPath
#anywhere, #attr, #child, #contains, #css, #descendant, generate, #name, #string, #text, #var, #varstring
Instance Method Details
#and(expression) ⇒ Object
Also known as:
&
254
255
256
|
# File 'lib/xpath/expression.rb', line 254
def and(expression)
Expression::And.new(current, expression)
end
|
#apply(variables = {}) ⇒ Object
285
286
287
|
# File 'lib/xpath/expression.rb', line 285
def apply(variables={})
Expression::Applied.new(current, variables)
end
|
#current ⇒ Object
223
224
225
|
# File 'lib/xpath/expression.rb', line 223
def current
self
end
|
#equals(expression) ⇒ Object
Also known as:
==
240
241
242
|
# File 'lib/xpath/expression.rb', line 240
def equals(expression)
Expression::Equality.new(current, expression)
end
|
#inverse ⇒ Object
Also known as:
~
264
265
266
|
# File 'lib/xpath/expression.rb', line 264
def inverse
Expression::Inverse.new(current)
end
|
#is(expression) ⇒ Object
245
246
247
|
# File 'lib/xpath/expression.rb', line 245
def is(expression)
Expression::Is.new(current, expression)
end
|
#next_sibling(*expressions) ⇒ Object
227
228
229
|
# File 'lib/xpath/expression.rb', line 227
def next_sibling(*expressions)
Expression::NextSibling.new(current, expressions)
end
|
#normalize ⇒ Object
Also known as:
n
#one_of(*expressions) ⇒ Object
236
237
238
|
# File 'lib/xpath/expression.rb', line 236
def one_of(*expressions)
Expression::OneOf.new(current, expressions)
end
|
#or(expression) ⇒ Object
Also known as:
|
249
250
251
|
# File 'lib/xpath/expression.rb', line 249
def or(expression)
Expression::Or.new(current, expression)
end
|
#to_s ⇒ Object
277
278
279
|
# File 'lib/xpath/expression.rb', line 277
def to_s
to_xpaths.join(' | ')
end
|
#to_xpath(predicate = nil) ⇒ Object
273
274
275
|
# File 'lib/xpath/expression.rb', line 273
def to_xpath(predicate=nil)
raise NotImplementedError, "please implement in subclass"
end
|
#to_xpaths ⇒ Object
281
282
283
|
# File 'lib/xpath/expression.rb', line 281
def to_xpaths
[to_xpath(:exact), to_xpath(:fuzzy)].uniq
end
|
#union(*expressions) ⇒ Object
Also known as:
+
259
260
261
|
# File 'lib/xpath/expression.rb', line 259
def union(*expressions)
Union.new(*[self, expressions].flatten)
end
|
#where(expression) ⇒ Object
Also known as:
[]
231
232
233
|
# File 'lib/xpath/expression.rb', line 231
def where(expression)
Expression::Where.new(current, expression)
end
|
#wrap_xpath(expression) ⇒ Object
294
295
296
297
298
299
300
|
# File 'lib/xpath/expression.rb', line 294
def wrap_xpath(expression)
case expression
when ::String then Expression::StringLiteral.new(expression)
when ::Symbol then Expression::Literal.new(expression)
else expression
end
end
|