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, Tag, 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, #tag, #text, #var, #varstring
Instance Method Details
#and(expression) ⇒ Object
Also known as:
&
261
262
263
|
# File 'lib/xpath/expression.rb', line 261
def and(expression)
Expression::And.new(current, expression)
end
|
#apply(variables = {}) ⇒ Object
292
293
294
|
# File 'lib/xpath/expression.rb', line 292
def apply(variables={})
Expression::Applied.new(current, variables)
end
|
#current ⇒ Object
230
231
232
|
# File 'lib/xpath/expression.rb', line 230
def current
self
end
|
#equals(expression) ⇒ Object
Also known as:
==
247
248
249
|
# File 'lib/xpath/expression.rb', line 247
def equals(expression)
Expression::Equality.new(current, expression)
end
|
#inverse ⇒ Object
Also known as:
~
271
272
273
|
# File 'lib/xpath/expression.rb', line 271
def inverse
Expression::Inverse.new(current)
end
|
#is(expression) ⇒ Object
252
253
254
|
# File 'lib/xpath/expression.rb', line 252
def is(expression)
Expression::Is.new(current, expression)
end
|
#next_sibling(*expressions) ⇒ Object
234
235
236
|
# File 'lib/xpath/expression.rb', line 234
def next_sibling(*expressions)
Expression::NextSibling.new(current, expressions)
end
|
#normalize ⇒ Object
Also known as:
n
#one_of(*expressions) ⇒ Object
243
244
245
|
# File 'lib/xpath/expression.rb', line 243
def one_of(*expressions)
Expression::OneOf.new(current, expressions)
end
|
#or(expression) ⇒ Object
Also known as:
|
256
257
258
|
# File 'lib/xpath/expression.rb', line 256
def or(expression)
Expression::Or.new(current, expression)
end
|
#to_s ⇒ Object
284
285
286
|
# File 'lib/xpath/expression.rb', line 284
def to_s
to_xpaths.join(' | ')
end
|
#to_xpath(predicate = nil) ⇒ Object
280
281
282
|
# File 'lib/xpath/expression.rb', line 280
def to_xpath(predicate=nil)
raise NotImplementedError, "please implement in subclass"
end
|
#to_xpaths ⇒ Object
288
289
290
|
# File 'lib/xpath/expression.rb', line 288
def to_xpaths
[to_xpath(:exact), to_xpath(:fuzzy)].uniq
end
|
#union(*expressions) ⇒ Object
Also known as:
+
266
267
268
|
# File 'lib/xpath/expression.rb', line 266
def union(*expressions)
Union.new(*[self, expressions].flatten)
end
|
#where(expression) ⇒ Object
Also known as:
[]
238
239
240
|
# File 'lib/xpath/expression.rb', line 238
def where(expression)
Expression::Where.new(current, expression)
end
|
#wrap_xpath(expression) ⇒ Object
301
302
303
304
305
306
307
|
# File 'lib/xpath/expression.rb', line 301
def wrap_xpath(expression)
case expression
when ::String then Expression::StringLiteral.new(expression)
when ::Symbol then Expression::Literal.new(expression)
else expression
end
end
|