Sha256: 04109ded833059ac528c258733ddb76dd54cb4fb7dfca0885b809de7bf9bc629
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
module Uncharted class Country attr_reader :alpha2, :alpha3, :name alias :code :alpha2 def initialize(alpha2, alpha3 = nil, name = nil) @alpha2 = alpha2 @alpha3 = alpha3 @name = name self.class.data[alpha2] = self end def inspect "#{@alpha2}: '#{@name}'" end def name(options = {}) I18n.t("countries.#{@alpha2}", {locale: options[:locale] || I18n.locale, default: @name}) end def to_s @alpha2 end def self.count countries.count end def self.find(objects) case objects when Array objects.collect {|c| data[c]} when Country objects else data[objects] end end def self.countries @data.values end def self.data @data ||= {} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uncharted-0.0.10 | lib/uncharted/country.rb |