Class: USGeo::Place

Inherits:
BaseRecord
  • Object
show all
Includes:
Area, Population
Defined in:
lib/us_geo/place.rb

Overview

Division of very large metropolitian areas into groups of approximately 2.5 million people.

Constant Summary

Constants inherited from BaseRecord

BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED

Instance Attribute Summary collapse

Attributes included from Area

#land_area, #water_area

Attributes included from Population

#housing_units, #population

Attributes inherited from BaseRecord

#status, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Area

#land_area_km, #percent_land, #total_area, #water_area_km

Methods included from Population

#housing_density, #housing_density_km, #population_density, #population_density_km

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Instance Attribute Details

#fips_class_codeString

Returns 2-character FIPS class code.

Returns:

  • (String)

    2-character FIPS class code.



# File 'lib/us_geo/place.rb', line 63

#geoidString

Returns 7-digit code for the place.

Returns:

  • (String)

    7-digit code for the place.



# File 'lib/us_geo/place.rb', line 51

#nameString

Returns Name of the place.

Returns:

  • (String)

    Name of the place.



# File 'lib/us_geo/place.rb', line 54

#short_nameString

Returns Short name of the place.

Returns:

  • (String)

    Short name of the place.



# File 'lib/us_geo/place.rb', line 57

#state_codeString

Returns 2-letter code for the state.

Returns:

  • (String)

    2-letter code for the state.



# File 'lib/us_geo/place.rb', line 60

Class Method Details

.load!(uri = nil) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/us_geo/place.rb', line 86

def load!(uri = nil)
  location = data_uri(uri || "places.csv")

  import! do
    load_data_file(location) do |row|
      load_record!(geoid: row["GEOID"]) do |record|
        record.gnis_id = row["GNIS ID"]
        record.name = row["Name"]
        record.short_name = row["Short Name"]
        record.state_code = row["State"]
        record.primary_county_geoid = row["County GEOID"]
        record.urban_area_geoid = row["Urban Area GEOID"]
        record.fips_class_code = row["FIPS Class"]
        record.population = row["Population"]
        record.housing_units = row["Housing Units"]
        record.land_area = row["Land Area"]
        record.water_area = row["Water Area"]
        record.lat = row["Latitude"]
        record.lng = row["Longitude"]
      end
    end
  end
end

Instance Method Details

#combined_statistical_areaCombinedStatisticalArea?

Returns Combined statistical area that the place is a part of.

Returns:



68
# File 'lib/us_geo/place.rb', line 68

delegate :combined_statistical_area, to: :primary_county, allow_nil: true

#core_based_statistical_areaCoreBasedStatisticalArea?

Returns Core-based statistical area that the place is a part of.

Returns:



72
# File 'lib/us_geo/place.rb', line 72

delegate :core_based_statistical_area, to: :primary_county, allow_nil: true

#full_nameString

Full name of the place as short name plus the state.

Returns:

  • (String)


81
82
83
# File 'lib/us_geo/place.rb', line 81

def full_name
  "#{short_name}, #{state_code}"
end

#metropolitan_divisionMetropolitanDivision?

Returns Metropolitan division that the place is a part of.

Returns:



76
# File 'lib/us_geo/place.rb', line 76

delegate :metropolitan_division, to: :primary_county, allow_nil: true