Class: USGeo::State
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- USGeo::State
- Includes:
- Area, Population
- Defined in:
- lib/us_geo/state.rb
Overview
U.S. state or territory.
Constant Summary collapse
- STATE_TYPE =
"state"- DISTRICT_TYPE =
"district"- TERRITORY_TYPE =
"territory"
Constants inherited from BaseRecord
BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED
Instance Attribute Summary collapse
-
#code ⇒ String
2-letter postal code of the state.
-
#fips ⇒ String
2-digit FIPS code of the state.
-
#name ⇒ String
Name of the state.
-
#type ⇒ String
Type of the state or territory.
Attributes included from Area
Attributes included from Population
Attributes inherited from BaseRecord
Class Method Summary collapse
Instance Method Summary collapse
- #district? ⇒ Boolean
-
#region(: region) ⇒ Region
Region the state is in.
- #state? ⇒ Boolean
- #territory? ⇒ Boolean
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
#code ⇒ String
Returns 2-letter postal code of the state.
|
|
# File 'lib/us_geo/state.rb', line 27
|
#fips ⇒ String
Returns 2-digit FIPS code of the state.
|
|
# File 'lib/us_geo/state.rb', line 33
|
#name ⇒ String
Returns Name of the state.
|
|
# File 'lib/us_geo/state.rb', line 30
|
#type ⇒ String
Returns Type of the state or territory.
|
|
# File 'lib/us_geo/state.rb', line 36
|
Class Method Details
.load!(uri = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/us_geo/state.rb', line 44 def load!(uri = nil) location = data_uri(uri || "states.csv") import! do load_data_file(location) do |row| load_record!(code: row["Code"]) do |record| record.name = row["Name"] record.type = row["Type"] record.fips = row["FIPS"] record.region_id = row["Region ID"] record.division_id = row["Division 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 |
Instance Method Details
#district? ⇒ Boolean
73 74 75 |
# File 'lib/us_geo/state.rb', line 73 def district? type == DISTRICT_TYPE end |
#region(: region) ⇒ Region
Returns Region the state is in.
41 |
# File 'lib/us_geo/state.rb', line 41 delegate :region, to: :division, allow_nil: true |
#state? ⇒ Boolean
65 66 67 |
# File 'lib/us_geo/state.rb', line 65 def state? type == STATE_TYPE end |
#territory? ⇒ Boolean
69 70 71 |
# File 'lib/us_geo/state.rb', line 69 def territory? type == TERRITORY_TYPE end |