96149efa
Isaac Lewis
working query browse
|
1
2
3
4
|
module Syspro
module BusinessObjects
module Parsers
class ComBrwParser
|
0f29247c
Isaac Lewis
add comfch and co...
|
5
|
attr_reader :doc
|
96149efa
Isaac Lewis
working query browse
|
6
|
|
0f29247c
Isaac Lewis
add comfch and co...
|
7
8
9
10
11
|
def initialize(doc)
@doc = doc
end
def parse
|
96149efa
Isaac Lewis
working query browse
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
next_prev_key = doc.first_element_child.xpath("NextPrevKey")
next_prev_key_obj = next_prev_key.children.map { |el|
if el.name == "text"
next
end
{
name: el.name,
text: el.text
}
}.compact
header_details = doc.first_element_child.xpath("HeaderDetails")
header_details_obj = header_details.children.map { |el|
if el.name == "text"
next
end
{
name: el.name,
text: el.text
}
}.compact
rows = doc.first_element_child.xpath('Row')
rows_obj = rows.map { |el|
|
0f29247c
Isaac Lewis
add comfch and co...
|
36
|
el.elements.map { |inner|
|
96149efa
Isaac Lewis
working query browse
|
37
|
{
|
0f29247c
Isaac Lewis
add comfch and co...
|
38
39
40
|
name: inner.name,
value: inner.xpath('Value').text,
data_type: inner.xpath('DataType').text
|
96149efa
Isaac Lewis
working query browse
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
}
}
}.flatten(1).compact
BrowseObject.new(
doc.first_element_child.xpath("Title").text,
rows_obj,
next_prev_key_obj,
header_details_obj
)
end
BrowseObject = Struct.new(:title, :rows, :next_prev_key, :header_details)
end
end
end
end
|