Class: TaxJp::Prefecture

Inherits:
Object
  • Object
show all
Defined in:
lib/tax_jp/prefecture.rb

Constant Summary collapse

@@prefectures_by_code =
{}
@@prefectures_by_name =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, name) ⇒ Prefecture

Returns a new instance of Prefecture.



7
8
9
10
# File 'lib/tax_jp/prefecture.rb', line 7

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/tax_jp/prefecture.rb', line 5

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/tax_jp/prefecture.rb', line 5

def name
  @name
end

Class Method Details

.allObject



20
21
22
# File 'lib/tax_jp/prefecture.rb', line 20

def self.all
  @@prefectures_by_code.values
end

.find_by_code(code) ⇒ Object



24
25
26
# File 'lib/tax_jp/prefecture.rb', line 24

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

.find_by_name(name) ⇒ Object



28
29
30
# File 'lib/tax_jp/prefecture.rb', line 28

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