Class: AddressParameter
- Inherits:
-
Object
- Object
- AddressParameter
- Defined in:
- lib/address_parameter.rb
Overview
This class represents an address in Rosette API.
Instance Attribute Summary collapse
-
#city ⇒ Object
city (optional).
-
#city_district ⇒ Object
city_district (optional).
-
#country ⇒ Object
country (optional).
-
#country_region ⇒ Object
country_region (optional).
-
#entrance ⇒ Object
entrance (optional).
-
#house ⇒ Object
house (optional).
-
#house_number ⇒ Object
house_number (optional).
-
#island ⇒ Object
island (optional).
-
#level ⇒ Object
level (optional).
-
#po_box ⇒ Object
po_box (optional).
-
#post_code ⇒ Object
post_code (optional).
-
#road ⇒ Object
road (optional).
-
#staircase ⇒ Object
staircase (optional).
-
#state ⇒ Object
state (optional).
-
#state_district ⇒ Object
state_district (optional).
-
#suburb ⇒ Object
suburb (optional).
-
#unit ⇒ Object
unit (optional).
-
#world_region ⇒ Object
world_region (optional).
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ AddressParameter
constructor
:notnew:.
-
#load_param ⇒ Object
Converts this class to Hash with its keys in lower CamelCase.
-
#to_hash ⇒ Object
Converts this class to Hash.
Constructor Details
#initialize(options = {}) ⇒ AddressParameter
:notnew:
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/address_parameter.rb', line 42 def initialize( = {}) #:notnew: = { house: nil, house_number: nil, road: nil, unit: nil, level: nil, staircase: nil, entrance: nil, suburb: nil, city_district: nil, city: nil, island: nil, state_district: nil, state: nil, country_region: nil, country: nil, world_region: nil, post_code: nil, po_box: nil }.update @house = [:house] @house_number = [:house_number] @road = [:road] @unit = [:unit] @level = [:level] @staircase = [:staircase] @entrance = [:entrance] @suburb = [:suburb] @city_district = [:city_district] @city = [:city] @island = [:island] @state_district = [:state_district] @state = [:state] @country_region = [:country_region] @country = [:country] @world_region = [:world_region] @post_code = [:post_code] @po_box = [:po_box] end |
Instance Attribute Details
#city ⇒ Object
city (optional)
24 25 26 |
# File 'lib/address_parameter.rb', line 24 def city @city end |
#city_district ⇒ Object
city_district (optional)
22 23 24 |
# File 'lib/address_parameter.rb', line 22 def city_district @city_district end |
#country ⇒ Object
country (optional)
34 35 36 |
# File 'lib/address_parameter.rb', line 34 def country @country end |
#country_region ⇒ Object
country_region (optional)
32 33 34 |
# File 'lib/address_parameter.rb', line 32 def country_region @country_region end |
#entrance ⇒ Object
entrance (optional)
18 19 20 |
# File 'lib/address_parameter.rb', line 18 def entrance @entrance end |
#house ⇒ Object
house (optional)
6 7 8 |
# File 'lib/address_parameter.rb', line 6 def house @house end |
#house_number ⇒ Object
house_number (optional)
8 9 10 |
# File 'lib/address_parameter.rb', line 8 def house_number @house_number end |
#island ⇒ Object
island (optional)
26 27 28 |
# File 'lib/address_parameter.rb', line 26 def island @island end |
#level ⇒ Object
level (optional)
14 15 16 |
# File 'lib/address_parameter.rb', line 14 def level @level end |
#po_box ⇒ Object
po_box (optional)
40 41 42 |
# File 'lib/address_parameter.rb', line 40 def po_box @po_box end |
#post_code ⇒ Object
post_code (optional)
38 39 40 |
# File 'lib/address_parameter.rb', line 38 def post_code @post_code end |
#road ⇒ Object
road (optional)
10 11 12 |
# File 'lib/address_parameter.rb', line 10 def road @road end |
#staircase ⇒ Object
staircase (optional)
16 17 18 |
# File 'lib/address_parameter.rb', line 16 def staircase @staircase end |
#state ⇒ Object
state (optional)
30 31 32 |
# File 'lib/address_parameter.rb', line 30 def state @state end |
#state_district ⇒ Object
state_district (optional)
28 29 30 |
# File 'lib/address_parameter.rb', line 28 def state_district @state_district end |
#suburb ⇒ Object
suburb (optional)
20 21 22 |
# File 'lib/address_parameter.rb', line 20 def suburb @suburb end |
#unit ⇒ Object
unit (optional)
12 13 14 |
# File 'lib/address_parameter.rb', line 12 def unit @unit end |
#world_region ⇒ Object
world_region (optional)
36 37 38 |
# File 'lib/address_parameter.rb', line 36 def world_region @world_region end |
Instance Method Details
#load_param ⇒ Object
Converts this class to Hash with its keys in lower CamelCase.
Returns the new Hash.
86 87 88 89 90 |
# File 'lib/address_parameter.rb', line 86 def load_param to_hash.select { |_key, value| value } .map { |key, value| [key.to_s.split('_').map(&:capitalize).join.sub!(/\D/, &:downcase), value] } .to_h end |
#to_hash ⇒ Object
Converts this class to Hash.
Returns the new Hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/address_parameter.rb', line 95 def to_hash { house: @house, house_number: @house_number, road: @road, unit: @unit, level: @level, staircase: @staircase, entrance: @entrance, suburb: @suburb, city_district: @city_district, city: @city, island: @island, state_district: @state_district, state: @state, country_region: @country_region, country: @country, world_region: @world_region, post_code: @post_code, po_box: @po_box } end |