lib/worldwide/region.rb in worldwide-0.3.0 vs lib/worldwide/region.rb in worldwide-0.4.0
- old
+ new
@@ -108,10 +108,14 @@
# E.g., "Sao Tome And[sic] Principe" for "ST".
# This name should _never_ be shown in the user interface.
# This name is the name that was traditionally returned by "country_db".
attr_reader :legacy_name
+ # Other names that may be used to refer to this region.
+ # E.g., "Czech Republic" is also known as "Czechia".
+ attr_accessor :name_alternates
+
# iso_code values of regions (subdivisions) within the same country that border this region.
# E.g., for CA-ON, the neighbouring zones are CA-MB, CA-NU and CA-QC.
attr_accessor :neighbours
# The ISO-3166-1 three-digit code for this region (returned as a string to preserve
@@ -436,10 +440,10 @@
def inspected_fields
INSPECTION_FIELDS.map { |field_name| "@#{field_name}=#{send(field_name).inspect}" }.join(", ")
end
def parent_country
- parents.find(&:country?)
+ @parent_country ||= parents.find(&:country?)
end
# Checks whether the given value is acceptable according to the regular expression defined for the country.
# @param value [String] for the postal code
# @return [Boolean]