Sha256: 340240191e59028cac6b3c63877eba8d129674cd5650b8180dbae09bd89df1fe
Contents?: true
Size: 1.05 KB
Versions: 6
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module USGeo # U.S. regional division composed of states. class Division < BaseRecord include Population include Area belongs_to :region, inverse_of: :divisions has_many :states, -> { not_removed }, inverse_of: :division validates :name, presence: true, length: {maximum: 30}, uniqueness: true # @!attribute id # @return [Integer] ID of the division. # @!attribute name # @return [String] Name of the division. class << self def load!(uri = nil) location = data_uri(uri || "divisions.csv") import! do load_data_file(location) do |row| load_record!(id: row["ID"]) do |record| record.name = row["Name"] record.region_id = row["Region ID"] 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
6 entries across 6 versions & 1 rubygems