Module: XPath
- Extended by:
- XPath
- Included in:
- XPath, Expression, HTML
- Defined in:
- lib/xpath.rb,
lib/xpath/html.rb,
lib/xpath/union.rb,
lib/xpath/version.rb,
lib/xpath/expression.rb
Defined Under Namespace
Modules: HTML
Classes: Expression, Union
Constant Summary
collapse
- VERSION =
'0.1.4'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.generate {|Expression::Self.new| ... } ⇒ Object
10
11
12
|
# File 'lib/xpath.rb', line 10
def self.generate
yield(Expression::Self.new)
end
|
Instance Method Details
#anywhere(expression) ⇒ Object
30
31
32
|
# File 'lib/xpath.rb', line 30
def anywhere(expression)
Expression::Anywhere.new(expression)
end
|
#attr(expression) ⇒ Object
34
35
36
|
# File 'lib/xpath.rb', line 34
def attr(expression)
Expression::Attribute.new(current, expression)
end
|
#child(*expressions) ⇒ Object
26
27
28
|
# File 'lib/xpath.rb', line 26
def child(*expressions)
Expression::Child.new(current, expressions)
end
|
#contains(expression) ⇒ Object
38
39
40
|
# File 'lib/xpath.rb', line 38
def contains(expression)
Expression::Contains.new(current, expression)
end
|
#css(selector) ⇒ Object
58
59
60
61
62
63
|
# File 'lib/xpath.rb', line 58
def css(selector)
paths = Nokogiri::CSS.xpath_for(selector).map do |selector|
Expression::CSS.new(current, Expression::Literal.new(selector))
end
Union.new(*paths)
end
|
#current ⇒ Object
14
15
16
|
# File 'lib/xpath.rb', line 14
def current
Expression::Self.new
end
|
#descendant(*expressions) ⇒ Object
22
23
24
|
# File 'lib/xpath.rb', line 22
def descendant(*expressions)
Expression::Descendant.new(current, expressions)
end
|
#name ⇒ Object
18
19
20
|
# File 'lib/xpath.rb', line 18
def name
Expression::Name.new(current)
end
|
#string ⇒ Object
50
51
52
|
# File 'lib/xpath.rb', line 50
def string
Expression::StringFunction.new(current)
end
|
#tag(name) ⇒ Object
54
55
56
|
# File 'lib/xpath.rb', line 54
def tag(name)
Expression::Tag.new(name)
end
|
#text ⇒ Object
42
43
44
|
# File 'lib/xpath.rb', line 42
def text
Expression::Text.new(current)
end
|
#var(name) ⇒ Object
46
47
48
|
# File 'lib/xpath.rb', line 46
def var(name)
Expression::Variable.new(name)
end
|
#varstring(name) ⇒ Object
65
66
67
|
# File 'lib/xpath.rb', line 65
def varstring(name)
var(name).string_literal
end
|