Class: KDL::Types::Country2
- Inherits:
-
Country
- Object
- Value
- Value::Custom
- Country
- KDL::Types::Country2
- Defined in:
- lib/kdl/types/country.rb
Constant Summary
Constants inherited from Country
KDL::Types::Country::COUNTRIES2, KDL::Types::Country::COUNTRIES3
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Country
#alpha2, #alpha3, #name, #numeric_code
Attributes inherited from Value::Custom
Attributes inherited from Value
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, format: nil, type: 'country-2') ⇒ Country2
constructor
A new instance of Country2.
Methods inherited from Value::Custom
Methods inherited from Value
#==, #as_type, from, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version
Constructor Details
#initialize(value, format: nil, type: 'country-2') ⇒ Country2
Returns a new instance of Country2.
32 33 34 |
# File 'lib/kdl/types/country.rb', line 32 def initialize(value, format: nil, type: 'country-2') super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Class Method Details
.call(value, type = 'country-2') ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/kdl/types/country.rb', line 36 def self.call(value, type = 'country-2') return nil unless value.is_a? ::KDL::Value::String country = COUNTRIES2[value.value.upcase] raise ArgumentError, 'invalid country-3' if country.nil? new(country, type: type) end |