Method: Jpnstacapi::Meta#getXml

Defined in:
lib/jpnstacapi/meta.rb

#getXmlObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jpnstacapi/meta.rb', line 12

def getXml
  xml = super
  xml = xml.elements['GET_META_INFO/METADATA_INF[1]']
  unless class_inf = xml.elements['CLASS_INF']
    return false
  end
  meta = {:id => @params[:statsDataId], :fields => Array.new }
  class_inf.elements.each('CLASS_OBJ') do |class_obj|
    field = {
      :id => 'api[' + class_obj.attributes['id'] + '][]',
      :name => class_obj.attributes['name'],
      :options => Array.new,
      :selected => Array.new,
      :description => class_obj.attributes['description']
    }
    class_obj.elements.each('CLASS') do |option|
      field[:options].push [
        option.attributes['name'],
        option.attributes['code']
      ]
      if option.attributes['level'] == '1'
        field[:selected].push option.attributes['code']
      end
    end
    meta[:fields].push field
  end
  return meta
end