Module: LapisLazuli::GenericModule::XPath
- Included in:
- LapisLazuli, Browser
- Defined in:
- lib/lapis_lazuli/generic/xpath.rb
Overview
Helper functions for XPath composition
Instance Method Summary collapse
-
#xp_and(first, second) ⇒ Object
Constructs xpath and clause.
-
#xp_contains(node, needle, separator = ' ') ⇒ Object
Return an xpath contains clause for e.g.
-
#xp_not(expr) ⇒ Object
Constructs xpath or clause.
-
#xp_or(first, second) ⇒ Object
Constructs xpath or clause.
Instance Method Details
#xp_and(first, second) ⇒ Object
Constructs xpath and clause
30 31 32 |
# File 'lib/lapis_lazuli/generic/xpath.rb', line 30 def xp_and(first, second) return "(#{first} and #{second})" end |
#xp_contains(node, needle, separator = ' ') ⇒ Object
Return an xpath contains clause for e.g. checking wether an element’s class attribute node contains a string. The optional third parameter determines how substrings are separated in the attribute node; the default is space for matching class names. Note that enclosing [ and ] are not included in the return value; this lets you more easily use and()/or()/not() operators.
23 24 25 26 |
# File 'lib/lapis_lazuli/generic/xpath.rb', line 23 def xp_contains(node, needle, separator = ' ') contains = "contains(concat('#{separator}', normalize-space(#{node}), '#{separator}'), '#{separator}#{needle}#{separator}')" return contains end |
#xp_not(expr) ⇒ Object
Constructs xpath or clause
42 43 44 |
# File 'lib/lapis_lazuli/generic/xpath.rb', line 42 def xp_not(expr) return "not(#{expr})" end |
#xp_or(first, second) ⇒ Object
Constructs xpath or clause
36 37 38 |
# File 'lib/lapis_lazuli/generic/xpath.rb', line 36 def xp_or(first, second) return "(#{first} or #{second})" end |