Sha256: 4f4bc46239ef2db0956aa8b385729bdb2aa33bee7b28c8252ffd2e6f39a749cc

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

class IsoCountry

	attr_accessor :name, :alpha2, :alpha3, :continent
    
  def initialize(data={})
  	if data and !data.nil?
	    data.each do |k, v|
	      send("#{k}=", v) if self.respond_to? "#{k}="
	    end
	  end
  end

  class << self

  	def all
  		COUNTRIES[:alpha2].values
  	end

  	def find_by_name(name)
  		COUNTRIES[:name][name]
  	end
  	alias_method :name, :find_by_name

  	def find_by_alpha2(code)
  		COUNTRIES[:alpha2][code.to_s.upcase]
  	end
  	alias_method :alpha2, :find_by_alpha2

  	def find_by_alpha3(code)
  		COUNTRIES[:alpha3][code.to_s.upcase]
  	end
  	alias_method :alpha3, :find_by_alpha3

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iso_countries_plus-0.2.0 lib/iso_countries_plus/iso_country.rb