Class: EvergreenHoldings::IDLParser

Inherits:
Object
  • Object
show all
Defined in:
lib/evergreen_holdings/idl_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(idl) ⇒ IDLParser

Returns a new instance of IDLParser.


5
6
7
# File 'lib/evergreen_holdings/idl_parser.rb', line 5

def initialize(idl)
  @idl = idl
end

Instance Method Details

#field_order_by_class(classes) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/evergreen_holdings/idl_parser.rb', line 9

def field_order_by_class(classes)
  classes.map do |idl_class|
    fields = @idl.xpath("//idl:class[@id='#{idl_class}']/idl:fields/idl:field", 'idl' => 'http://opensrf.org/spec/IDL/base/v1')
                 .map.with_index { |field, index| [field['name'], index] }
    [idl_class, fields.to_h]
  end.to_h
end