rexle 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rexle.rb +13 -4
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -86,13 +86,14 @@ class Rexle
|
|
86
86
|
end
|
87
87
|
attr_search = items.join(' ')
|
88
88
|
end
|
89
|
+
condition = "[" + condition
|
89
90
|
|
90
91
|
end
|
91
92
|
|
92
93
|
wildcard = xpath_value[0,2] == '//'
|
93
94
|
|
94
95
|
if wildcard then
|
95
|
-
return scan_match(self, element_name, rlist)
|
96
|
+
return scan_match(self, element_name, attr_search, condition, rlist)
|
96
97
|
end
|
97
98
|
|
98
99
|
return_elements = @child_lookup.map.with_index.select {|x| x[0][0] == element_name or element_name == '*'}
|
@@ -120,10 +121,18 @@ class Rexle
|
|
120
121
|
rlist
|
121
122
|
end
|
122
123
|
|
123
|
-
def scan_match(nodes, element, rlist)
|
124
|
+
def scan_match(nodes, element, attr_search, condition, rlist)
|
124
125
|
nodes.children.each.with_index do |x, i|
|
125
|
-
|
126
|
-
|
126
|
+
if x.name == element
|
127
|
+
h = x.attributes
|
128
|
+
if attr_search then
|
129
|
+
rlist << x if h and eval(attr_search)
|
130
|
+
else
|
131
|
+
rlist << x
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
x.xpath('//' + element + condition, rlist) unless x.children.empty?
|
127
136
|
end
|
128
137
|
rlist
|
129
138
|
end
|