Class: Jpnstacapi::List
- Inherits:
-
Api
- Object
- Api
- Jpnstacapi::List
show all
- Defined in:
- lib/jpnstacapi/list.rb
Instance Method Summary
collapse
Methods inherited from Api
#httpRequest, #setParameters
Constructor Details
#initialize ⇒ List
Returns a new instance of List.
3
4
5
6
|
# File 'lib/jpnstacapi/list.rb', line 3
def initialize
super
@url = @url + 'getStatsList'
end
|
Instance Method Details
#fetch(code) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/jpnstacapi/list.rb', line 13
def fetch code
require 'date'
e = Date.today
s = Date.new(e.year-10, e.month)
r = [s.strftime('%Y%m'), e.strftime('%Y%m')].join('-')
@params[:statsCode] = code
@params[:searchKind] = 1
@params[:surveyYears] = r
return getXml
end
|
#getXml ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/jpnstacapi/list.rb', line 26
def getXml
xml = super
xml = xml.elements['GET_STATS_LIST/DATALIST_INF[1]']
list = {:name => "name", :stats => Array.new}
list[:count] = xml.elements['NUMBER'].text.to_i
xml.elements.each('LIST_INF') do |list_inf|
stat = {
:id => list_inf.attributes['id'],
:stat_name => list_inf.elements['STAT_NAME'].text,
:stat_code => list_inf.elements['STAT_NAME'].attributes['code'],
:gov_name => list_inf.elements['GOV_ORG'].text,
:gov_code => list_inf.elements['GOV_ORG'].attributes['code']
}
if list_inf.elements['STATISTICS_NAME']
stat[:statistics_name] = list_inf.elements['STATISTICS_NAME'].text
end
if list_inf.elements['TITLE']
stat[:title] = list_inf.elements['TITLE'].text
end
if (list_inf.elements['CYCLE'])
stat[:cycle] = list_inf.elements['CYCLE'].text
end
if (list_inf.elements['SURVEY_DATE'])
stat[:survey_date] = list_inf.elements['SURVEY_DATE'].text
end
if (list_inf.elements['OPEN_DATE'])
stat[:open_date] = list_inf.elements['OPEN_DATE'].text
end
list[:stats].push stat
end
return list
end
|
#overview ⇒ Object
8
9
10
11
|
# File 'lib/jpnstacapi/list.rb', line 8
def overview
@params[:statsNameList] = 'Y'
return getXml
end
|