Sha256: d1e129cdc871e27b6815538be8f1967bda9154b2c1bd04e932e85995d8cd8b9a

Contents?: true

Size: 671 Bytes

Versions: 62

Compression:

Stored size: 671 Bytes

Contents

require 'yaml'

module TaxJp
  class Prefecture
    attr_reader :code, :name

    def initialize(code, name)
      @code = code
      @name = name
    end

    @@prefectures_by_code = {}
    @@prefectures_by_name = {}
    TaxJp::Utils.load_yaml('ιƒ½ι“εΊœηœŒ.yml').each do |key, value|
      code = "%02d" % key.to_i
      p = Prefecture.new(code, value)
      @@prefectures_by_code[p.code] = @@prefectures_by_name[p.name] = p
    end

    def self.all
      @@prefectures_by_code.values
    end

    def self.find_by_code(code)
      @@prefectures_by_code["%02d" % code.to_i]
    end

    def self.find_by_name(name)
      @@prefectures_by_name[name]
    end

  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
tax_jp-1.2.12 lib/tax_jp/prefecture.rb
tax_jp-1.2.11 lib/tax_jp/prefecture.rb
tax_jp-1.2.10 lib/tax_jp/prefecture.rb
tax_jp-1.2.9 lib/tax_jp/prefecture.rb
tax_jp-1.2.8 lib/tax_jp/prefecture.rb
tax_jp-1.2.7 lib/tax_jp/prefecture.rb
tax_jp-1.2.6 lib/tax_jp/prefecture.rb
tax_jp-1.2.5 lib/tax_jp/prefecture.rb
tax_jp-1.2.4 lib/tax_jp/prefecture.rb
tax_jp-1.2.3 lib/tax_jp/prefecture.rb
tax_jp-1.2.2 lib/tax_jp/prefecture.rb
tax_jp-1.2.1 lib/tax_jp/prefecture.rb
tax_jp-1.2.0 lib/tax_jp/prefecture.rb
tax_jp-1.1.12 lib/tax_jp/prefecture.rb
tax_jp-1.1.11 lib/tax_jp/prefecture.rb
tax_jp-1.1.10 lib/tax_jp/prefecture.rb
tax_jp-1.1.9 lib/tax_jp/prefecture.rb
tax_jp-1.1.8 lib/tax_jp/prefecture.rb
tax_jp-1.1.7 lib/tax_jp/prefecture.rb
tax_jp-1.1.6 lib/tax_jp/prefecture.rb