class StateHelper::Provinces

Attributes

provinces[R]

Public Class Methods

new() click to toggle source
# File lib/state_helper/provinces.rb, line 5
def initialize
  @provinces = {
    "Alberta" => "AB",
    "British Columbia" => "BC",
    "Manitoba" => "MB",
    "New Brunswick" => "NB",
    "Newfoundland" => "NL",
    "Nova Scotia" => "NS",
    "Northwest Territories" => "NT",
    "Nunavut" => "NU",
    "Ontario" => "ON",
    "Prince Edward Island" => "PE",
    "Quebec" => "QC",
    "Saskatchewan" => "SK",
    "Yukon" => "YT"
  }
end

Public Instance Methods

codes() click to toggle source
# File lib/state_helper/provinces.rb, line 23
def codes
  @provinces.values
end
get_code_by_name(name) click to toggle source
# File lib/state_helper/provinces.rb, line 35
def get_code_by_name name
  @provinces[name.titleize]
end
get_name_by_code(code) click to toggle source
# File lib/state_helper/provinces.rb, line 31
def get_name_by_code code
  @provinces.select {|key, value| value == code.upcase}.first.first
end
names() click to toggle source
# File lib/state_helper/provinces.rb, line 27
def names
  @provinces.keys
end