Module: XPath::DSL::TopLevel

Included in:
XPath, XPath, ExpressionLevel, HTML
Defined in:
lib/xpath/dsl.rb

Instance Method Summary collapse

Instance Method Details

#anywhere(*expressions) ⇒ Object



32
33
34
# File 'lib/xpath/dsl.rb', line 32

def anywhere(*expressions)
  Expression.new(:anywhere, expressions)
end

#attr(expression) ⇒ Object



36
37
38
# File 'lib/xpath/dsl.rb', line 36

def attr(expression)
  Expression.new(:attribute, current, expression)
end

#axis(name, tag_name = :*) ⇒ Object



20
21
22
# File 'lib/xpath/dsl.rb', line 20

def axis(name, tag_name=:*)
  Expression.new(:axis, current, name, tag_name)
end

#child(*expressions) ⇒ Object



16
17
18
# File 'lib/xpath/dsl.rb', line 16

def child(*expressions)
  Expression.new(:child, current, expressions)
end

#contains(expression) ⇒ Object



40
41
42
# File 'lib/xpath/dsl.rb', line 40

def contains(expression)
  Expression.new(:contains, current, expression)
end

#css(selector) ⇒ Object



66
67
68
# File 'lib/xpath/dsl.rb', line 66

def css(selector)
  Expression.new(:css, current, Literal.new(selector))
end

#currentObject



4
5
6
# File 'lib/xpath/dsl.rb', line 4

def current
  Expression.new(:this_node)
end

#descendant(*expressions) ⇒ Object



12
13
14
# File 'lib/xpath/dsl.rb', line 12

def descendant(*expressions)
  Expression.new(:descendant, current, expressions)
end

#nameObject



8
9
10
# File 'lib/xpath/dsl.rb', line 8

def name
  Expression.new(:node_name, current)
end

#next_sibling(*expressions) ⇒ Object



24
25
26
# File 'lib/xpath/dsl.rb', line 24

def next_sibling(*expressions)
  Expression.new(:next_sibling, current, expressions)
end

#previous_sibling(*expressions) ⇒ Object



28
29
30
# File 'lib/xpath/dsl.rb', line 28

def previous_sibling(*expressions)
  Expression.new(:previous_sibling, current, expressions)
end

#starts_with(expression) ⇒ Object



44
45
46
# File 'lib/xpath/dsl.rb', line 44

def starts_with(expression)
  Expression.new(:starts_with, current, expression)
end

#stringObject



52
53
54
# File 'lib/xpath/dsl.rb', line 52

def string
  Expression.new(:string_function, current)
end

#string_lengthObject



62
63
64
# File 'lib/xpath/dsl.rb', line 62

def string_length
  Expression.new(:string_length_function, current)
end

#substring(expression1, expression2 = nil) ⇒ Object



56
57
58
59
60
# File 'lib/xpath/dsl.rb', line 56

def substring(expression1, expression2=nil)
  expressions = [expression1]
  expressions << expression2 unless expression2.nil?
  Expression.new(:substring_function, current, *expressions)
end

#textObject



48
49
50
# File 'lib/xpath/dsl.rb', line 48

def text
  Expression.new(:text, current)
end