Sha256: c44954358a2b5f04f4b80d0b6d73ccbef196e8c8821878e66a5c11a3a7c74737

Contents?: true

Size: 749 Bytes

Versions: 5

Compression:

Stored size: 749 Bytes

Contents

# frozen_string_literal: true

require 'companies_house_hub/base_model'

module CompaniesHouseHub
  class Address < BaseModel
    attr_reader :address_line1, :address_line2, :postal_code, :locality, :country, :care_of
    attr_reader :premises

    alias line1 address_line1
    alias line2 address_line2

    def initialize(json = {})
      @address_line1 = json.dig(:address_line_1)
      @address_line2 = json.dig(:address_line_2)
      @country = json.dig(:country)
      @postal_code = json.dig(:postal_code)
      @locality = json.dig(:locality)
      @care_of = json.dig(:care_of)
      @premises = json.dig(:premises)
    end

    def full
      [@address_line1, @address_line2, @locality, @postal_code].compact.join(', ')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
companies_house_hub-0.1.12 lib/companies_house_hub/models/address.rb
companies_house_hub-0.1.11 lib/companies_house_hub/models/address.rb
companies_house_hub-0.1.10 lib/companies_house_hub/models/address.rb
companies_house_hub-0.1.9 lib/companies_house_hub/models/address.rb
companies_house_hub-0.1.8 lib/companies_house_hub/models/address.rb