Class: TaxJp::Prefecture
- Inherits:
-
Object
- Object
- TaxJp::Prefecture
- Defined in:
- lib/tax_jp/prefecture.rb
Constant Summary collapse
- @@prefectures_by_code =
{}
- @@prefectures_by_name =
{}
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, name) ⇒ Prefecture
constructor
A new instance of Prefecture.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/tax_jp/prefecture.rb', line 5 def code @code end |
#name ⇒ Object (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
.all ⇒ Object
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 |