Class: Util

Inherits:
Object
  • Object
show all
Defined in:
lib/util.rb

Overview

Simple collection of Utilities useful to govsdk users

Class Method Summary collapse

Class Method Details

.lookup_state_name(state_name) ⇒ Object

2 letter code for state that most closely matches state_name, or nil.



99
100
101
102
103
104
105
106
107
# File 'lib/util.rb', line 99

def self.lookup_state_name(state_name)
  return state_name.upcase if STATE_ABBR.has_key?(state_name.upcase)
  matches = STATE_ABBR.select { |k,v| v.include? state_name.capitalize}
  if matches.length == 1
    return matches[0][0]
  else
    return nil
  end
end