lib/uncharted/territory.rb in uncharted-0.0.8 vs lib/uncharted/territory.rb in uncharted-0.0.9
- old
+ new
@@ -30,11 +30,11 @@
end
class Territory
- attr_reader :abbr, :code, :country, :country_code, :name, :type
+ attr_reader :abbr, :code, :country, :country_code, :type
def initialize(code, type, name)
@code = code
@type = type
@name = name
@@ -42,9 +42,13 @@
@country = Country.find(@country_code)
Territory.data[code] = self
@country.subdivisions << self if @country
end
+ def name(options = {})
+ I18n.t("territories.#{@country_code}#{@abbr}", {locale: options[:locale] || I18n.locale}, default: @name)
+ end
+
def to_s
@abbr
end
def self.find(object)
\ No newline at end of file