Module: MyRepresentatives::Abbreviatable

Instance Method Summary collapse

Instance Method Details

#state_abbreviation(str) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/my_representatives/abbreviatable.rb', line 4

def state_abbreviation(str)
  if Static::STATES.include?(str.upcase)
    str.upcase
  elsif str.upcase.strip == "AUSTRALIAN CAPITAL TERRITORY"
    "ACT"
  elsif str.upcase.strip == "NEW SOUTH WALES"
    "NSW"
  elsif str.upcase.strip == "NORTHERN TERRITORY"
    "NT"
  elsif str.upcase.strip == "QUEENSLAND"
    "QLD"
  elsif str.upcase.strip == "SOUTH AUSTRALIA"
    "SA"
  elsif str.upcase.strip == "TASMANIA"
    "TAS"
  elsif str.upcase.strip == "VICTORIA"
    "VIC"
  elsif str.upcase.strip == "WESTERN AUSTRALIA"
    "WA"
  else
    "UNKNOWN" # Will likely trigger an error elsewhere in the app, but that's okay
  end
end