Module: ISO3166::ConversionMethods

Included in:
Country
Defined in:
lib/countries/country/conversion_methods.rb

Instance Method Summary collapse

Instance Method Details

#from_alpha2_to_alpha3(alpha2) ⇒ String

Returns ISO 3166 alpha-3 country code.

Parameters:

  • alpha2 (String)

    ISO 3166 alpha-2 country code.

Returns:

  • (String)

    ISO 3166 alpha-3 country code.



7
8
9
# File 'lib/countries/country/conversion_methods.rb', line 7

def from_alpha2_to_alpha3(alpha2)
  find_country_by_alpha2(alpha2)&.alpha3
end

#from_alpha3_to_alpha2(alpha3) ⇒ String

Returns ISO 3166 alpha-2 country code.

Parameters:

  • alpha3 (String)

    ISO 3166 alpha-3 country code.

Returns:

  • (String)

    ISO 3166 alpha-2 country code.



13
14
15
# File 'lib/countries/country/conversion_methods.rb', line 13

def from_alpha3_to_alpha2(alpha3)
  find_country_by_alpha3(alpha3)&.alpha2
end