Class: MrCommon::Country
- Inherits:
-
Object
- Object
- MrCommon::Country
- Defined in:
- app/models/mr_common/country.rb
Overview
Wrapper doing common tasks with the Carmen gem
Class Method Summary collapse
-
.all(top = []) ⇒ Array<Array<String, String>>
An array of label-value pairs for building country select options.
-
.codes ⇒ Array<String>
Two letter country codes in alphabetical order.
-
.name_for(code) ⇒ String
The name of the country for that code.
-
.names ⇒ Array<String>
Country names in alphabetical order.
Class Method Details
.all(top = []) ⇒ Array<Array<String, String>>
Returns an array of label-value pairs for building country select options.
11 12 13 14 15 16 17 18 19 |
# File 'app/models/mr_common/country.rb', line 11 def all(top = []) all_countries = label_value_pairs.dup top.reverse_each do |alpha2| all_countries = promote_one(all_countries, alpha2) end all_countries end |
.codes ⇒ Array<String>
Returns two letter country codes in alphabetical order.
22 23 24 |
# File 'app/models/mr_common/country.rb', line 22 def codes Carmen::Country.all.map(&:code).sort end |
.name_for(code) ⇒ String
Returns the name of the country for that code.
33 34 35 |
# File 'app/models/mr_common/country.rb', line 33 def name_for(code) Carmen::Country.alpha_2_coded(code).name end |
.names ⇒ Array<String>
Returns country names in alphabetical order.
27 28 29 |
# File 'app/models/mr_common/country.rb', line 27 def names Carmen::Country.all.map(&:name).sort end |