Module: Nikkou::Nokogiri::XML::NodeSet

Includes:
Drillable, Findable
Defined in:
lib/nikkou/nokogiri/xml/node_set.rb

Instance Method Summary collapse

Methods included from Findable

#find

Methods included from Drillable

#drill

Instance Method Details

#attr_equals(attribute, string) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 8

def attr_equals(attribute, string)
  list = select do |node|
    return false if node.attr(attribute).nil?
    node.attr(attribute) == string
  end
  self.class.new(document, list)
end

#attr_includes(attribute, string) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 16

def attr_includes(attribute, string)
  list = select do |node|
    return false if node.attr(attribute).nil?
    node.attr(attribute).include?(string)
  end
  self.class.new(document, list)
end

#attr_matches(attribute, pattern) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 24

def attr_matches(attribute, pattern)
  list = []
  each do |node|
    next if node.attr(attribute).nil?
    if node.attr(attribute).match(pattern)
      node.matches = $~.to_a
      list << node
    end
  end
  self.class.new(document, list)
end

#text_equals(string) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 36

def text_equals(string)
  list = select do |node|
    next if node.is_a?(::Nokogiri::XML::Text)
    node.text == string
  end
  self.class.new(document, list)
end

#text_includes(string) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 44

def text_includes(string)
  list = select do |node|
    next if node.is_a?(::Nokogiri::XML::Text)
    node.text.include?(string)
  end
  self.class.new(document, list)
end

#text_matches(pattern) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/nikkou/nokogiri/xml/node_set.rb', line 52

def text_matches(pattern)
  list = []
  each do |node|
    next if node.is_a?(::Nokogiri::XML::Text)
    if node.text.match(pattern)
      node.matches = $~.to_a
      list << node
    end
  end
  self.class.new(document, list)
end