Module: TaxJp::SocialInsurances::Utils
- Included in:
- TaxJp::SocialInsurance
- Defined in:
- lib/tax_jp/social_insurances/utils.rb
Instance Method Summary collapse
Instance Method Details
#convert_to_prefecture_code(value) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tax_jp/social_insurances/utils.rb', line 3 def convert_to_prefecture_code(value) ret = nil if value.is_a?(TaxJp::Prefecture) ret = value.code elsif value.to_s =~ /[0-9]{2}/ ret = value.to_s else p = TaxJp::Prefecture.find_by_name(value.to_s) if p ret = p.code else raise TypeError.new(value.class) end end ret end |