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
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/tottori-opendata-catalog/command.rb', line 14
def to_csv(cache:true)
require 'csv'
CSV(csv = '') do |line|
data = TottoriOpenDataCatalog::Proxy.get(cache:cache)
line << %w{
category_name
resource_name formats department division tags
redistribution_allowed commercial_use_allowed
provider tel description comment
year month day
repeat_rule_frequency repeat_rule_interval repeat_rule_description
}
data[:categories].each do |category|
category[:resources].each do |resource|
row = []
row << category[:name]
row << resource[:name]
row << resource[:formats].join(' ')
row << resource[:department]
row << resource[:division]
row << resource[:tags].join(' ')
row << resource[:redistribution_allowed]
row << resource[:commercial_use_allowed]
row << resource[:provider]
row << resource[:tel]
row << resource[:description]
row << resource[:comment]
row << resource[:year]
row << resource[:month]
row << resource[:day]
row << resource[:repeat_rule][:frequency]
row << resource[:repeat_rule][:interval]
row << resource[:repeat_rule][:description]
line << row
end
end
end
return csv
end
|