module State
Constants
- CODES
- STATE_TO_CODE
- STFIPS
Public Class Methods
member?(state)
click to toggle source
# File lib/us_states_enhanced.rb, line 137 def self.member?(state) CODES.member? normalize(state) rescue InvalidState false end
normalize(state)
click to toggle source
# File lib/us_states_enhanced.rb, line 147 def self.normalize(state) return state.upcase if CODES.member? state.upcase return STATE_TO_CODE.fetch state.downcase rescue KeyError raise InvalidState end
states()
click to toggle source
# File lib/us_states_enhanced.rb, line 143 def self.states CODES.values end
stfips(state)
click to toggle source
# File lib/us_states_enhanced.rb, line 132 def self.stfips(state) code = normalize(state) stfips_by_code(code) end
stfips_by_code(code)
click to toggle source
# File lib/us_states_enhanced.rb, line 123 def self.stfips_by_code(code) begin state = CODES[code.upcase] [STFIPS.assoc(state)].flatten.last || nil rescue nil end end