class StateHelper::States
Attributes
states[R]
Public Class Methods
new()
click to toggle source
# File lib/state_helper/states.rb, line 5 def initialize @states = { 'Alabama' => 'AL', 'Alaska' => 'AK', 'Arizona' => 'AZ', 'Arkansas' => 'AR', 'California' => 'CA', 'Colorado' => 'CO', 'Connecticut' => 'CT', 'Delaware' => 'DE', 'Florida' => 'FL', 'Georgia' => 'GA', 'Guam' => 'GU', 'Hawaii' => 'HI', 'Idaho' => 'ID', 'Illinois' => 'IL', 'Indiana' => 'IN', 'Iowa' => 'IA', 'Kansas' => 'KS', 'Kentucky' => 'KY', 'Louisiana' => 'LA', 'Maine' => 'ME', 'Maryland' => 'MD', 'Massachusetts' => 'MA', 'Michigan' => 'MI', 'Minnesota' => 'MN', 'Mississippi' => 'MS', 'Missouri' => 'MO', 'Montana' => 'MT', 'Nebraska' => 'NE', 'Nevada' => 'NV', 'New Hampshire' => 'NH', 'New Jersey' => 'NJ', 'New Mexico' => 'NM', 'New York' => 'NY', 'North Carolina' => 'NC', 'North Dakota' => 'ND', 'Ohio' => 'OH', 'Oklahoma' => 'OK', 'Oregon' => 'OR', 'Pennsylvania' => 'PA', 'Rhode Island' => 'RI', 'South Carolina' => 'SC', 'South Dakota' => 'SD', 'Tennessee' => 'TN', 'Texas' => 'TX', 'Utah' => 'UT', 'Vermont' => 'VT', 'Virginia' => 'VA', 'Virgin Islands' => 'VI', 'Washington' => 'WA', 'West Virginia' => 'WV', 'Wisconsin' => 'WI', 'Wyoming' => 'WY', 'Washington DC' => 'DC' } end
Public Instance Methods
codes()
click to toggle source
# File lib/state_helper/states.rb, line 63 def codes @states.values end
get_code_by_name(name)
click to toggle source
# File lib/state_helper/states.rb, line 79 def get_code_by_name name @states[name.titleize] end
get_name_by_code(code)
click to toggle source
# File lib/state_helper/states.rb, line 71 def get_name_by_code code if good_code(code) @states.select {|key, value| value == code.upcase}.first.first else code end end
good_code(code)
click to toggle source
# File lib/state_helper/states.rb, line 83 def good_code code @states.map {|key, value| value}.include? code.upcase end
names()
click to toggle source
# File lib/state_helper/states.rb, line 67 def names @states.keys end