Class: LocalGovCode::LocalGov
- Inherits:
-
Object
- Object
- LocalGovCode::LocalGov
- Defined in:
- lib/local_gov_code.rb
Overview
各地方公共団体を扱うクラス
Instance Attribute Summary collapse
-
#kana ⇒ Object
readonly
Returns the value of attribute kana.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prefkana ⇒ Object
readonly
Returns the value of attribute prefkana.
-
#prefname ⇒ Object
readonly
Returns the value of attribute prefname.
Instance Method Summary collapse
-
#check_ok? ⇒ Boolean
テスト用.
- #code ⇒ Object
- #fullname ⇒ Object
-
#initialize(code, prefname, name, prefkana, kana) ⇒ LocalGov
constructor
A new instance of LocalGov.
Constructor Details
#initialize(code, prefname, name, prefkana, kana) ⇒ LocalGov
Returns a new instance of LocalGov.
61 62 63 64 65 66 67 68 |
# File 'lib/local_gov_code.rb', line 61 def initialize(code, prefname, name, prefkana, kana) @code = code.to_i / 10 # 6桁目チェックコードは除く @checksum = code.to_i % 10 @prefname = prefname @name = name @prefkana = prefkana @kana = kana end |
Instance Attribute Details
#kana ⇒ Object (readonly)
Returns the value of attribute kana.
59 60 61 |
# File 'lib/local_gov_code.rb', line 59 def kana @kana end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
59 60 61 |
# File 'lib/local_gov_code.rb', line 59 def name @name end |
#prefkana ⇒ Object (readonly)
Returns the value of attribute prefkana.
59 60 61 |
# File 'lib/local_gov_code.rb', line 59 def prefkana @prefkana end |
#prefname ⇒ Object (readonly)
Returns the value of attribute prefname.
59 60 61 |
# File 'lib/local_gov_code.rb', line 59 def prefname @prefname end |
Instance Method Details
#check_ok? ⇒ Boolean
テスト用
79 80 81 |
# File 'lib/local_gov_code.rb', line 79 def check_ok? @checksum == checksum end |
#code ⇒ Object
70 71 72 |
# File 'lib/local_gov_code.rb', line 70 def code sprintf("%05d", @code) end |
#fullname ⇒ Object
74 75 76 |
# File 'lib/local_gov_code.rb', line 74 def fullname "#{prefname}#{name}" end |