Sha256: bb7cc209a7499a36931e1bde561da71a0b2ad197a4fbe1d0f0b2f516202f76b2
Contents?: true
Size: 577 Bytes
Versions: 3
Compression:
Stored size: 577 Bytes
Contents
require 'json' module TimeZoneConverter class JsonDataTransformer def initialize(path: 'data/cities') @path = path end def call json_new = Hash.new { |hash, key| hash[key] = {} } Dir["#{@path}/*.json"].each do |json_file| json = JSON.parse(File.read(json_file)) json.each do |item| data = item.last json_new[data['accentcity']] = [data['latitude'], data['longitude']] end end File.open("#{@path}/cities.json", "w") do |f| f.write(json_new.to_json) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems