Sha256: 4d276716003ed5a7ca0edc7ec43b6d0380445ede00119998646e96655ef2ad00
Contents?: true
Size: 1004 Bytes
Versions: 7
Compression:
Stored size: 1004 Bytes
Contents
# frozen_string_literal: true module USGeo # U.S. region. class Region < BaseRecord include Population include Area has_many :divisions, -> { not_removed }, inverse_of: :region has_many :states, -> { not_removed }, inverse_of: :region validates :name, presence: true, length: {maximum: 30}, uniqueness: true # @!attribute id # @return [Integer] ID of the region. # @!attribute name # @return [String] Name of the region. class << self def load!(uri = nil) location = data_uri(uri || "regions.csv") import! do load_data_file(location) do |row| load_record!(id: row["ID"]) do |record| record.name = row["Name"] record.population = row["Population"] record.housing_units = row["Housing Units"] record.land_area = row["Land Area"] record.water_area = row["Water Area"] end end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems