Class: LocalGovCode::LocalGov

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

Overview

各地方公共団体を扱うクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#kanaObject (readonly)

Returns the value of attribute kana.



59
60
61
# File 'lib/local_gov_code.rb', line 59

def kana
  @kana
end

#nameObject (readonly)

Returns the value of attribute name.



59
60
61
# File 'lib/local_gov_code.rb', line 59

def name
  @name
end

#prefkanaObject (readonly)

Returns the value of attribute prefkana.



59
60
61
# File 'lib/local_gov_code.rb', line 59

def prefkana
  @prefkana
end

#prefnameObject (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

テスト用

Returns:

  • (Boolean)


79
80
81
# File 'lib/local_gov_code.rb', line 79

def check_ok?
  @checksum == checksum
end

#codeObject



70
71
72
# File 'lib/local_gov_code.rb', line 70

def code
  sprintf("%05d", @code)
end

#fullnameObject



74
75
76
# File 'lib/local_gov_code.rb', line 74

def fullname
  "#{prefname}#{name}"
end