Class: Jpzip::Town
- Inherits:
-
Data
- Object
- Data
- Jpzip::Town
- Defined in:
- lib/jpzip/types.rb
Overview
Town corresponds to one element of ZipcodeEntry#towns.
Fields match the JSON shape served by the CDN (snake_case).
Instance Attribute Summary collapse
-
#kana ⇒ Object
readonly
Returns the value of attribute kana.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#roma ⇒ Object
readonly
Returns the value of attribute roma.
-
#town ⇒ Object
readonly
Returns the value of attribute town.
Class Method Summary collapse
-
.from_hash(h) ⇒ Object
Build a Town from a parsed JSON hash.
Instance Method Summary collapse
Instance Attribute Details
#kana ⇒ Object (readonly)
Returns the value of attribute kana
7 8 9 |
# File 'lib/jpzip/types.rb', line 7 def kana @kana end |
#note ⇒ Object (readonly)
Returns the value of attribute note
7 8 9 |
# File 'lib/jpzip/types.rb', line 7 def note @note end |
#roma ⇒ Object (readonly)
Returns the value of attribute roma
7 8 9 |
# File 'lib/jpzip/types.rb', line 7 def roma @roma end |
#town ⇒ Object (readonly)
Returns the value of attribute town
7 8 9 |
# File 'lib/jpzip/types.rb', line 7 def town @town end |
Class Method Details
.from_hash(h) ⇒ Object
Build a Town from a parsed JSON hash. Unknown keys are ignored so the SDK keeps working when the protocol grows new optional fields.
10 11 12 13 14 15 16 17 |
# File 'lib/jpzip/types.rb', line 10 def self.from_hash(h) new( town: h["town"] || "", kana: h["kana"] || "", roma: h["roma"] || "", note: h["note"] ) end |
Instance Method Details
#to_h ⇒ Object
19 20 21 22 23 |
# File 'lib/jpzip/types.rb', line 19 def to_h base = { town: town, kana: kana, roma: roma } base[:note] = note if note base end |