Transforming a json now, eh
This commit is contained in:
parent
fe2a7feba4
commit
2478f6c441
@ -1,6 +1,6 @@
|
|||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config`
|
||||||
# on 2020-01-09 20:09:37 -0500 using RuboCop version 0.78.0.
|
# on 2020-01-11 15:25:31 -0500 using RuboCop version 0.78.0.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
|
@ -11,19 +11,17 @@ class CPIFetcher
|
|||||||
resp = fetch_raw_response
|
resp = fetch_raw_response
|
||||||
return nil unless resp['Results']['series']
|
return nil unless resp['Results']['series']
|
||||||
|
|
||||||
data = resp['Results']['series'].first['data']
|
resp['Results']['series'].first['data']
|
||||||
{
|
|
||||||
start: start_cpi_value(data),
|
|
||||||
latest: latest_cpi_value(data)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cpi_csv
|
def cpi_csv
|
||||||
values = cpi
|
|
||||||
CSV.generate do |csv|
|
CSV.generate do |csv|
|
||||||
csv << %w[year value]
|
csv << %w[year period period_name value]
|
||||||
csv << [start_year, values.fetch(:start)]
|
cpi.each do |rec|
|
||||||
csv << [end_year, values.fetch(:latest)]
|
csv << %w[
|
||||||
|
year period periodName value
|
||||||
|
].map { |k| rec.fetch(k) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user