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:
&
260
261
262
|
# File 'lib/xpath/expression.rb', line 260
def and(expression)
Expression::And.new(current, expression)
end
|
#apply(variables = {}) ⇒ Object
291
292
293
|
# File 'lib/xpath/expression.rb', line 291
def apply(variables={})
Expression::Applied.new(current, variables)
end
|
#current ⇒ Object
229
230
231
|
# File 'lib/xpath/expression.rb', line 229
def current
self
end
|
#equals(expression) ⇒ Object
Also known as:
==
246
247
248
|
# File 'lib/xpath/expression.rb', line 246
def equals(expression)
Expression::Equality.new(current, expression)
end
|
#inverse ⇒ Object
Also known as:
~
270
271
272
|
# File 'lib/xpath/expression.rb', line 270
def inverse
Expression::Inverse.new(current)
end
|
#is(expression) ⇒ Object
251
252
253
|
# File 'lib/xpath/expression.rb', line 251
def is(expression)
Expression::Is.new(current, expression)
end
|
#next_sibling(*expressions) ⇒ Object
233
234
235
|
# File 'lib/xpath/expression.rb', line 233
def next_sibling(*expressions)
Expression::NextSibling.new(current, expressions)
end
|
#normalize ⇒ Object
Also known as:
n
#one_of(*expressions) ⇒ Object
242
243
244
|
# File 'lib/xpath/expression.rb', line 242
def one_of(*expressions)
Expression::OneOf.new(current, expressions)
end
|
#or(expression) ⇒ Object
Also known as:
|
255
256
257
|
# File 'lib/xpath/expression.rb', line 255
def or(expression)
Expression::Or.new(current, expression)
end
|
#to_s ⇒ Object
283
284
285
|
# File 'lib/xpath/expression.rb', line 283
def to_s
to_xpaths.join(' | ')
end
|
#to_xpath(predicate = nil) ⇒ Object
279
280
281
|
# File 'lib/xpath/expression.rb', line 279
def to_xpath(predicate=nil)
raise NotImplementedError, "please implement in subclass"
end
|
#to_xpaths ⇒ Object
287
288
289
|
# File 'lib/xpath/expression.rb', line 287
def to_xpaths
[to_xpath(:exact), to_xpath(:fuzzy)].uniq
end
|
#union(*expressions) ⇒ Object
Also known as:
+
265
266
267
|
# File 'lib/xpath/expression.rb', line 265
def union(*expressions)
Union.new(*[self, expressions].flatten)
end
|
#where(expression) ⇒ Object
Also known as:
[]
237
238
239
|
# File 'lib/xpath/expression.rb', line 237
def where(expression)
Expression::Where.new(current, expression)
end
|
#wrap_xpath(expression) ⇒ Object
300
301
302
303
304
305
306
|
# File 'lib/xpath/expression.rb', line 300
def wrap_xpath(expression)
case expression
when ::String then Expression::StringLiteral.new(expression)
when ::Symbol then Expression::Literal.new(expression)
else expression
end
end
|