class Booker::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/models/country.rb, line 9 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/models/country.rb, line 7 def country_code; IDS_TO_ISO_CODES[self.ID]; end