# frozen_string_literal: true require "japan_municipality/version" require "csv" class JapanMunicipality def self.all DATA[2..-1].map do |data| new(data) end end def initialize(data) @area_code = data[0] @prefecture = data[1] @subprefecture = data[2] @subprefecture_furigana = data[3] @municipality = data[4] @municipality_furigana = data[5] @merger_dissolution_date = data[6] @has_merger_dissolution_infomation = data[7] end # https://www.e-stat.go.jp/municipalities/cities/areacode DATA = CSV.read("data/municipalities.csv").freeze private_constant :DATA end