Class: AtlasEngine::Gb::ValidationTranscriber::ParsedAddress

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(country_code:, building_num: nil, dependent_street: nil, street: nil, unit_type: nil, unit_num: nil, double_dependent_locality: nil, dependent_locality: nil, post_town: nil, county: nil, province_code: nil, zip: nil) ⇒ ParsedAddress



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 62

def initialize(
  country_code:,
  building_num: nil,
  dependent_street: nil,
  street: nil,
  unit_type: nil,
  unit_num: nil,
  double_dependent_locality: nil,
  dependent_locality: nil,
  post_town: nil,
  county: nil,
  province_code: nil,
  zip: nil
)
  @building_num = building_num
  @dependent_street = dependent_street
  @street = street
  @unit_type = unit_type
  @unit_num = unit_num
  @double_dependent_locality = double_dependent_locality
  @dependent_locality = dependent_locality
  @post_town = post_town
  @county = county
  @province_code = province_code
  @country_code = country_code
  @zip = zip
end

Instance Attribute Details

#building_numObject

may be alphanumeric, e.g. “2A”



11
12
13
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 11

def building_num
  @building_num
end

#country_codeObject

Returns the value of attribute country_code.



41
42
43
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 41

def country_code
  @country_code
end

#countyObject

deprecated in 1996, but still permitted



35
36
37
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 35

def county
  @county
end

#dependent_localityObject

Returns the value of attribute dependent_locality.



29
30
31
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 29

def dependent_locality
  @dependent_locality
end

#dependent_streetObject

what Royal Mail calls a dependent thoroughfare



14
15
16
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 14

def dependent_street
  @dependent_street
end

#double_dependent_localityObject

Returns the value of attribute double_dependent_locality.



26
27
28
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 26

def double_dependent_locality
  @double_dependent_locality
end

#post_townObject

the :city field may contain “#post_town, #county



32
33
34
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 32

def post_town
  @post_town
end

#province_codeObject

Returns the value of attribute province_code.



38
39
40
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 38

def province_code
  @province_code
end

#streetObject

what Royal Mail calls a thoroughfare



17
18
19
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 17

def street
  @street
end

#unit_numObject

Returns the value of attribute unit_num.



23
24
25
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 23

def unit_num
  @unit_num
end

#unit_typeObject

Returns the value of attribute unit_type.



20
21
22
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 20

def unit_type
  @unit_type
end

#zipObject

Returns the value of attribute zip.



44
45
46
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 44

def zip
  @zip
end

Instance Method Details

#==(other) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb', line 91

def ==(other)
  @country_code.presence == other.country_code.presence &&
    @building_num.presence == other.building_num.presence &&
    @dependent_street.presence == other.dependent_street.presence &&
    @street.presence == other.street.presence &&
    @unit_type.presence == other.unit_type.presence &&
    @unit_num.presence == other.unit_num.presence &&
    @double_dependent_locality.presence == other.double_dependent_locality.presence &&
    @dependent_locality.presence == other.dependent_locality.presence &&
    @post_town.presence == other.post_town.presence &&
    @county.presence == other.county.presence &&
    @zip.presence == other.zip.presence &&

    # If no province is given in GB, we'll infer it with a postcode lookup
    (
      @province_code.presence == other.province_code.presence ||
        inferred_province_code == other.send(:inferred_province_code)
    )
end