Class: Validiso::Countries
- Inherits:
-
Object
- Object
- Validiso::Countries
- Defined in:
- lib/validiso/countries.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_alpha2(val) ⇒ Object
9 10 11 |
# File 'lib/validiso/countries.rb', line 9 def find_alpha2(val) new.find(type: 'alpha2', value: val) end |
.find_alpha3(val) ⇒ Object
12 13 14 |
# File 'lib/validiso/countries.rb', line 12 def find_alpha3(val) new.find(type: 'alpha3', value: val) end |
.find_code(val) ⇒ Object
6 7 8 |
# File 'lib/validiso/countries.rb', line 6 def find_code(val) new.find(type: 'code', value: val) end |
Instance Method Details
#find(type:, value:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/validiso/countries.rb', line 17 def find(type:, value:) value = value.to_s case type.to_s when 'code' Validiso::Data.codes[value] when 'alpha2' Validiso::Data.alpha2[value] when 'alpha3' Validiso::Data.alpha3[value] end end |