Module: JapanPostcoder
- Defined in:
- lib/japan_postcoder.rb,
lib/version.rb
Overview
Main module for JapanPostcoder Contains methods to convert Japanese postal code to address in string or hash format
Defined Under Namespace
Classes: Address, InvalidPostalCodeError
Constant Summary collapse
- VERSION =
'0.1.3'
Class Method Summary collapse
-
.to_address(postal_code, romaji: false) ⇒ Object
Returns the address in string format Example: ‘神奈川県川崎市多摩区西生田’.
-
.to_address_hash(postal_code, romaji: false) ⇒ Object
Returns the address in hash format Example: { postcode: ‘2140037’, prefecture: ‘神奈川県’, city: ‘川崎市’, ward: ‘多摩区’, district: ‘西生田’ }.
Class Method Details
.to_address(postal_code, romaji: false) ⇒ Object
Returns the address in string format Example: ‘神奈川県川崎市多摩区西生田’
16 17 18 19 20 21 22 |
# File 'lib/japan_postcoder.rb', line 16 def self.to_address(postal_code, romaji: false) validate_postal_code!(postal_code) address = get_address(postal_code, romaji: romaji) address.to_s(romaji: romaji) end |
.to_address_hash(postal_code, romaji: false) ⇒ Object
Returns the address in hash format Example:
postcode: '2140037',
prefecture: '神奈川県',
city: '川崎市',
ward: '多摩区',
district: '西生田'
33 34 35 36 37 38 39 |
# File 'lib/japan_postcoder.rb', line 33 def self.to_address_hash(postal_code, romaji: false) validate_postal_code!(postal_code) address = get_address(postal_code, romaji: romaji) address.to_h end |