recordx-parser 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/recordx-parser.rb +13 -4
- metadata +1 -1
data/lib/recordx-parser.rb
CHANGED
@@ -10,6 +10,12 @@ class RecordxParser
|
|
10
10
|
parse(s){|x| yield(x)}
|
11
11
|
end
|
12
12
|
|
13
|
+
def to_a()
|
14
|
+
@a
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
13
19
|
def parse(s)
|
14
20
|
|
15
21
|
s.instance_eval{
|
@@ -28,13 +34,16 @@ class RecordxParser
|
|
28
34
|
|
29
35
|
if raw_records then
|
30
36
|
node_name = raw_records[/<(\w+)/,1]
|
31
|
-
|
37
|
+
a_records = raw_records.strip.split(/(?=<#{node_name}[^>]*>)/)
|
38
|
+
records = fetch_records(a_records)
|
32
39
|
end
|
33
40
|
|
34
41
|
[root_name, "", {}, [*summary], ['records', "",{}, *records]]
|
35
42
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def fetch_records(a_records)
|
47
|
+
a_records.map {|x| yield(x)}
|
39
48
|
end
|
40
49
|
end
|