Sha256: 8cc73bba1fe8efb66c26df0d9392ce8f15f82de22665cbd0fcd7c8017c25712c

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

module Loqate
  module Address
    # A result from the address retrieve service.
    class DetailedAddress
      # For the first version, this will be a flat structure, exactly as it is defined in Loqate's API.
      # But this many attributes is too much for a single object to hold.
      #
      # @api private
      #
      ATTRIBUTES = %i[
        admin_area_code
        admin_area_name
        barcode
        block
        building_name
        building_number
        city
        company
        country_iso2
        country_iso3
        country_iso_number
        country_name
        data_level
        department
        district
        domestic_id
        field1
        field2
        field3
        field4
        field5
        field6
        field7
        field8
        field9
        field10
        field11
        field12
        field13
        field14
        field15
        field16
        field17
        field18
        field19
        field20
        id
        label
        language
        language_alternatives
        line1
        line2
        line3
        line4
        line5
        neighbourhood
        po_box_number
        postal_code
        province
        province_code
        province_name
        secondary_street
        sorting_number1
        sorting_number2
        street
        sub_building
        type
      ].freeze

      ATTRIBUTES.each do |attribute|
        attr_reader attribute
      end

      def initialize(options = {})
        options.each_pair do |key, value|
          instance_variable_set("@#{key}", value) if ATTRIBUTES.include?(key)
        end
      end

      def ==(other)
        other.is_a?(DetailedAddress) && id == other.id
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
loqate-0.12.0 lib/loqate/address/detailed_address.rb
loqate-0.11.1 lib/loqate/address/detailed_address.rb
loqate-0.11.0 lib/loqate/address/detailed_address.rb
loqate-0.10.4 lib/loqate/address/detailed_address.rb
loqate-0.10.3 lib/loqate/address/detailed_address.rb
loqate-0.10.2 lib/loqate/address/detailed_address.rb
loqate-0.10.1 lib/loqate/address/detailed_address.rb
loqate-0.10.0 lib/loqate/address/detailed_address.rb
loqate-0.9.0 lib/loqate/address/detailed_address.rb
loqate-0.8.0 lib/loqate/address/detailed_address.rb
loqate-0.7.0 lib/loqate/address/detailed_address.rb