Class: Jpnstacapi::Meta
- Inherits:
-
Api
- Object
- Api
- Jpnstacapi::Meta
show all
- Defined in:
- lib/jpnstacapi/meta.rb
Instance Method Summary
collapse
Methods inherited from Api
#httpRequest, #setParameters
Constructor Details
#initialize ⇒ Meta
Returns a new instance of Meta.
2
3
4
5
|
# File 'lib/jpnstacapi/meta.rb', line 2
def initialize
super
@url = @url + 'getMetaInfo'
end
|
Instance Method Details
#fetch(id) ⇒ Object
7
8
9
10
|
# File 'lib/jpnstacapi/meta.rb', line 7
def fetch id
@params[:statsDataId] = id
return getXml
end
|
#getXml ⇒ Object
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
|