Blame view

lib/syspro/business_objects/parsers/comfch_parser.rb 631 Bytes
dc8aa5b6   Joe Weakley   Rubocop corrections
1
2
  # frozen_string_literal: true
  
0f29247c   Isaac Lewis   add comfch and co...
3
4
5
6
7
8
9
10
11
12
13
14
15
  module Syspro
    module BusinessObjects
      module Parsers
        class ComFchParser
          attr_reader :doc
  
          def initialize(doc)
            @doc = doc
          end
  
          def parse
            table_name = doc.first_element_child.name
            columns = doc.first_element_child.elements
dc8aa5b6   Joe Weakley   Rubocop corrections
16
            columns_obj = columns.map do |el|
0f29247c   Isaac Lewis   add comfch and co...
17
              { name: el.name, value: el.children.text }
dc8aa5b6   Joe Weakley   Rubocop corrections
18
            end.compact
0f29247c   Isaac Lewis   add comfch and co...
19
20
21
22
23
24
25
26
27
28
29
30
  
            FetchObject.new(
              table_name,
              columns_obj
            )
          end
  
          FetchObject = Struct.new(:table_name, :columns)
        end
      end
    end
  end