-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conversion methods for country codes
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module ISO3166 | ||
module ConversionMethods | ||
# @param alpha2 [String] ISO 3166 alpha-2 country code. | ||
# @return [String] ISO 3166 alpha-3 country code. | ||
def from_alpha2_to_alpha3(alpha2) | ||
find_country_by_alpha2(alpha2)&.alpha3 | ||
end | ||
|
||
# @param alpha3 [String] ISO 3166 alpha-3 country code. | ||
# @return [String] ISO 3166 alpha-2 country code. | ||
def from_alpha3_to_alpha2(alpha3) | ||
find_country_by_alpha3(alpha3)&.alpha2 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters