Class: Postio::Models::Address

Inherits:
Data
  • Object
show all
Defined in:
lib/postio/models.rb

Overview

Address — full PAF + OS record. Many fields are optional.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#address_line_1Object (readonly)

Returns the value of attribute address_line_1

Returns:

  • (Object)

    the current value of address_line_1



41
42
43
# File 'lib/postio/models.rb', line 41

def address_line_1
  @address_line_1
end

#address_line_2Object (readonly)

Returns the value of attribute address_line_2

Returns:

  • (Object)

    the current value of address_line_2



41
42
43
# File 'lib/postio/models.rb', line 41

def address_line_2
  @address_line_2
end

#address_line_3Object (readonly)

Returns the value of attribute address_line_3

Returns:

  • (Object)

    the current value of address_line_3



41
42
43
# File 'lib/postio/models.rb', line 41

def address_line_3
  @address_line_3
end

#building_nameObject (readonly)

Returns the value of attribute building_name

Returns:

  • (Object)

    the current value of building_name



41
42
43
# File 'lib/postio/models.rb', line 41

def building_name
  @building_name
end

#building_numberObject (readonly)

Returns the value of attribute building_number

Returns:

  • (Object)

    the current value of building_number



41
42
43
# File 'lib/postio/models.rb', line 41

def building_number
  @building_number
end

#countryObject (readonly)

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



41
42
43
# File 'lib/postio/models.rb', line 41

def country
  @country
end

#countyObject (readonly)

Returns the value of attribute county

Returns:

  • (Object)

    the current value of county



41
42
43
# File 'lib/postio/models.rb', line 41

def county
  @county
end

#delivery_point_suffixObject (readonly)

Returns the value of attribute delivery_point_suffix

Returns:

  • (Object)

    the current value of delivery_point_suffix



41
42
43
# File 'lib/postio/models.rb', line 41

def delivery_point_suffix
  @delivery_point_suffix
end

#department_nameObject (readonly)

Returns the value of attribute department_name

Returns:

  • (Object)

    the current value of department_name



41
42
43
# File 'lib/postio/models.rb', line 41

def department_name
  @department_name
end

#dependent_localityObject (readonly)

Returns the value of attribute dependent_locality

Returns:

  • (Object)

    the current value of dependent_locality



41
42
43
# File 'lib/postio/models.rb', line 41

def dependent_locality
  @dependent_locality
end

#dependent_thoroughfareObject (readonly)

Returns the value of attribute dependent_thoroughfare

Returns:

  • (Object)

    the current value of dependent_thoroughfare



41
42
43
# File 'lib/postio/models.rb', line 41

def dependent_thoroughfare
  @dependent_thoroughfare
end

#districtObject (readonly)

Returns the value of attribute district

Returns:

  • (Object)

    the current value of district



41
42
43
# File 'lib/postio/models.rb', line 41

def district
  @district
end

#double_dependent_localityObject (readonly)

Returns the value of attribute double_dependent_locality

Returns:

  • (Object)

    the current value of double_dependent_locality



41
42
43
# File 'lib/postio/models.rb', line 41

def double_dependent_locality
  @double_dependent_locality
end

#eastingsObject (readonly)

Returns the value of attribute eastings

Returns:

  • (Object)

    the current value of eastings



41
42
43
# File 'lib/postio/models.rb', line 41

def eastings
  @eastings
end

#latitudeObject (readonly)

Returns the value of attribute latitude

Returns:

  • (Object)

    the current value of latitude



41
42
43
# File 'lib/postio/models.rb', line 41

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude

Returns:

  • (Object)

    the current value of longitude



41
42
43
# File 'lib/postio/models.rb', line 41

def longitude
  @longitude
end

#northingsObject (readonly)

Returns the value of attribute northings

Returns:

  • (Object)

    the current value of northings



41
42
43
# File 'lib/postio/models.rb', line 41

def northings
  @northings
end

#organisation_nameObject (readonly)

Returns the value of attribute organisation_name

Returns:

  • (Object)

    the current value of organisation_name



41
42
43
# File 'lib/postio/models.rb', line 41

def organisation_name
  @organisation_name
end

#po_boxObject (readonly)

Returns the value of attribute po_box

Returns:

  • (Object)

    the current value of po_box



41
42
43
# File 'lib/postio/models.rb', line 41

def po_box
  @po_box
end

#post_townObject (readonly)

Returns the value of attribute post_town

Returns:

  • (Object)

    the current value of post_town



41
42
43
# File 'lib/postio/models.rb', line 41

def post_town
  @post_town
end

#postcodeObject (readonly)

Returns the value of attribute postcode

Returns:

  • (Object)

    the current value of postcode



41
42
43
# File 'lib/postio/models.rb', line 41

def postcode
  @postcode
end

#postcode_inwardObject (readonly)

Returns the value of attribute postcode_inward

Returns:

  • (Object)

    the current value of postcode_inward



41
42
43
# File 'lib/postio/models.rb', line 41

def postcode_inward
  @postcode_inward
end

#postcode_outwardObject (readonly)

Returns the value of attribute postcode_outward

Returns:

  • (Object)

    the current value of postcode_outward



41
42
43
# File 'lib/postio/models.rb', line 41

def postcode_outward
  @postcode_outward
end

#postcode_typeObject (readonly)

Returns the value of attribute postcode_type

Returns:

  • (Object)

    the current value of postcode_type



41
42
43
# File 'lib/postio/models.rb', line 41

def postcode_type
  @postcode_type
end

#sub_building_nameObject (readonly)

Returns the value of attribute sub_building_name

Returns:

  • (Object)

    the current value of sub_building_name



41
42
43
# File 'lib/postio/models.rb', line 41

def sub_building_name
  @sub_building_name
end

#thoroughfareObject (readonly)

Returns the value of attribute thoroughfare

Returns:

  • (Object)

    the current value of thoroughfare



41
42
43
# File 'lib/postio/models.rb', line 41

def thoroughfare
  @thoroughfare
end

#udprnObject (readonly)

Returns the value of attribute udprn

Returns:

  • (Object)

    the current value of udprn



41
42
43
# File 'lib/postio/models.rb', line 41

def udprn
  @udprn
end

#wardObject (readonly)

Returns the value of attribute ward

Returns:

  • (Object)

    the current value of ward



41
42
43
# File 'lib/postio/models.rb', line 41

def ward
  @ward
end

Class Method Details

.from_hash(h) ⇒ Object



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/postio/models.rb', line 50

def self.from_hash(h)
  new(
    udprn:                       h["udprn"].to_i,
    postcode:                    h["postcode"].to_s,
    postcode_outward:            h["postcode_outward"],
    postcode_inward:             h["postcode_inward"],
    postcode_type:               h["postcode_type"],
    address_line_1:              h["address_line_1"],
    address_line_2:              h["address_line_2"],
    address_line_3:              h["address_line_3"],
    post_town:                   h["post_town"],
    organisation_name:           h["organisation_name"],
    department_name:             h["department_name"],
    building_name:               h["building_name"],
    building_number:             h["building_number"],
    sub_building_name:           h["sub_building_name"],
    po_box:                      h["po_box"],
    thoroughfare:                h["thoroughfare"],
    dependent_thoroughfare:      h["dependent_thoroughfare"],
    dependent_locality:          h["dependent_locality"],
    double_dependent_locality:   h["double_dependent_locality"],
    delivery_point_suffix:       h["delivery_point_suffix"],
    country:                     h["country"],
    county:                      h["county"],
    district:                    h["district"],
    ward:                        h["ward"],
    latitude:                    h["latitude"]&.to_f,
    longitude:                   h["longitude"]&.to_f,
    eastings:                    h["eastings"]&.to_i,
    northings:                   h["northings"]&.to_i
  )
end