Class: USGeo::State

Inherits:
BaseRecord
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Class Method Details

.load!(uri = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/us_geo/state.rb', line 26

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"]
      end
    end
  end
end

Instance Method Details

#district?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/us_geo/state.rb', line 51

def district?
  type == DISTRICT_TYPE
end

#state?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/us_geo/state.rb', line 43

def state?
  type == STATE_TYPE
end

#territory?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/us_geo/state.rb', line 47

def territory?
  type == TERRITORY_TYPE
end