Sha256: 71b47737502bfb868aff3bef111f56865dc3704ce96068a2032a71128ae26aa7

Contents?: true

Size: 456 Bytes

Versions: 5

Compression:

Stored size: 456 Bytes

Contents

# rubocop:disable Style/StructInheritance
module Renalware
  class Country < Struct.new(:name, :code)

    def self.all
      @all ||= data.map{ |row| Country.new(row[0], row[1]) }
    end

    def self.data
      CSV.read(Engine.root.join("config", "countries.csv"), headers: true)
    end

    def self.code_for(country_name)
      country = all.find{ |cntry| cntry.name == country_name }
      return unless country
      country.code
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta8 app/values/renalware/country.rb
renalware-core-2.0.0.pre.beta7 app/values/renalware/country.rb
renalware-core-2.0.0.pre.beta6 app/values/renalware/country.rb
renalware-core-2.0.0.pre.beta5 app/values/renalware/country.rb
renalware-core-2.0.0.pre.beta4 app/values/renalware/country.rb