Sha256: ce91315a9ac8b0f0495308b9a5bf438e24321463ca2bbe6eeb6d74de8664187f

Contents?: true

Size: 549 Bytes

Versions: 2

Compression:

Stored size: 549 Bytes

Contents

require 'singleton'

class IsoCountryCodes
  class Code
    include Singleton

    def name
      self.class.name
    end

    def numeric
      self.class.numeric
    end

    def alpha2
      self.class.alpha2
    end

    def alpha3
      self.class.alpha3
    end

    class << self
      attr_accessor :name, :numeric, :alpha2, :alpha3

      @@codes = []
      def inherited(code) #:nodoc:
        super
        @@codes << code.instance if self == IsoCountryCodes::Code
      end

      def all
        @@codes.uniq
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alexrabarts-iso_country_codes-0.1.1 lib/iso_country_codes/code.rb
alexrabarts-iso_country_codes-0.1.2 lib/iso_country_codes/code.rb