rexle 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +4 -6
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -14,14 +14,14 @@ class Rexle
|
|
14
14
|
|
15
15
|
if fn_match.nil? then
|
16
16
|
procs = {
|
17
|
-
Array: proc {|x| x.length == 1 ? x[0] : x},
|
17
|
+
Array: proc {|x| x.compact!; x.length == 1 ? x[0] : x},
|
18
18
|
String: proc {|x| x}
|
19
19
|
}
|
20
20
|
bucket = []
|
21
21
|
result = @doc.xpath(path, bucket)
|
22
22
|
|
23
23
|
procs[result.class.to_s.to_sym].call(result)
|
24
|
-
|
24
|
+
|
25
25
|
else
|
26
26
|
m, xpath_value = fn_match.captures
|
27
27
|
method(m.to_sym).call(xpath_value)
|
@@ -96,17 +96,15 @@ class Rexle
|
|
96
96
|
end
|
97
97
|
|
98
98
|
return_elements = @child_lookup.map.with_index.select {|x| x[0][0] == element_name or element_name == '*'}
|
99
|
-
|
100
99
|
|
101
100
|
if return_elements.length > 0 then
|
102
101
|
if a.empty? then
|
103
|
-
return_elements.map.with_index {|x,i| filter(x, i+1, attr_search)}
|
102
|
+
rlist = return_elements.map.with_index {|x,i| filter(x, i+1, attr_search)}
|
104
103
|
else
|
105
104
|
return_elements.map.with_index do |x,i|
|
106
105
|
rtn_element = filter(x, i+1, attr_search){|e| r = e.xpath(a.join('/'), rlist); r || e }
|
107
106
|
|
108
107
|
rlist << rtn_element
|
109
|
-
rtn_element
|
110
108
|
end
|
111
109
|
end
|
112
110
|
else
|
@@ -220,4 +218,4 @@ class Rexle
|
|
220
218
|
@doc.xpath(path).flatten.compact.length
|
221
219
|
end
|
222
220
|
|
223
|
-
end
|
221
|
+
end
|