class Booker::V4::Models::Country

Constants

IDS_TO_ISO_CODES

ISO 3166-1 alpha-2 Codes

Public Class Methods

from_country_code(code) click to toggle source
# File lib/booker/v4/models/country.rb, line 10
def self.from_country_code(code)
  country = self.new ID: IDS_TO_ISO_CODES.detect{|k, v| v == code}.try(:[], 0)
  if country.ID.nil?
    raise ArgumentError, 'Country code not recognized'
  else
    country
  end
end

Public Instance Methods

country_code() click to toggle source
# File lib/booker/v4/models/country.rb, line 8
def country_code; IDS_TO_ISO_CODES[self.ID]; end