Class: AddressParameter

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

Overview

This class represents an address in Rosette API.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {}) #:notnew:
  options = {
    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 options
  @house = options[:house]
  @house_number = options[:house_number]
  @road = options[:road]
  @unit = options[:unit]
  @level = options[:level]
  @staircase = options[:staircase]
  @entrance = options[:entrance]
  @suburb = options[:suburb]
  @city_district = options[:city_district]
  @city = options[:city]
  @island = options[:island]
  @state_district = options[:state_district]
  @state = options[:state]
  @country_region = options[:country_region]
  @country = options[:country]
  @world_region = options[:world_region]
  @post_code = options[:post_code]
  @po_box = options[:po_box]
end

Instance Attribute Details

#cityObject

city (optional)



24
25
26
# File 'lib/address_parameter.rb', line 24

def city
  @city
end

#city_districtObject

city_district (optional)



22
23
24
# File 'lib/address_parameter.rb', line 22

def city_district
  @city_district
end

#countryObject

country (optional)



34
35
36
# File 'lib/address_parameter.rb', line 34

def country
  @country
end

#country_regionObject

country_region (optional)



32
33
34
# File 'lib/address_parameter.rb', line 32

def country_region
  @country_region
end

#entranceObject

entrance (optional)



18
19
20
# File 'lib/address_parameter.rb', line 18

def entrance
  @entrance
end

#houseObject

house (optional)



6
7
8
# File 'lib/address_parameter.rb', line 6

def house
  @house
end

#house_numberObject

house_number (optional)



8
9
10
# File 'lib/address_parameter.rb', line 8

def house_number
  @house_number
end

#islandObject

island (optional)



26
27
28
# File 'lib/address_parameter.rb', line 26

def island
  @island
end

#levelObject

level (optional)



14
15
16
# File 'lib/address_parameter.rb', line 14

def level
  @level
end

#po_boxObject

po_box (optional)



40
41
42
# File 'lib/address_parameter.rb', line 40

def po_box
  @po_box
end

#post_codeObject

post_code (optional)



38
39
40
# File 'lib/address_parameter.rb', line 38

def post_code
  @post_code
end

#roadObject

road (optional)



10
11
12
# File 'lib/address_parameter.rb', line 10

def road
  @road
end

#staircaseObject

staircase (optional)



16
17
18
# File 'lib/address_parameter.rb', line 16

def staircase
  @staircase
end

#stateObject

state (optional)



30
31
32
# File 'lib/address_parameter.rb', line 30

def state
  @state
end

#state_districtObject

state_district (optional)



28
29
30
# File 'lib/address_parameter.rb', line 28

def state_district
  @state_district
end

#suburbObject

suburb (optional)



20
21
22
# File 'lib/address_parameter.rb', line 20

def suburb
  @suburb
end

#unitObject

unit (optional)



12
13
14
# File 'lib/address_parameter.rb', line 12

def unit
  @unit
end

#world_regionObject

world_region (optional)



36
37
38
# File 'lib/address_parameter.rb', line 36

def world_region
  @world_region
end

Instance Method Details

#load_paramObject

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_hashObject

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