Sha256: 39c8fac4b8953cce83df03e86801f11ef194efc72b9c8c6e53073ba1fd5c84ea

Contents?: true

Size: 834 Bytes

Versions: 15

Compression:

Stored size: 834 Bytes

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/PostalAddress
      module PostalAddress
        # Builds a full address using the lines of the address and the postcode.
        #
        # @return [String, String] the full address of the Grom::Node or an empty string.
        def full_address
          address_array.join(', ')
        end

        private

        def address_array
          address_array = []
          (1..5).each do |i|
            if respond_to?("addressLine#{i}".to_sym)
              address_array << instance_variable_get("@addressLine#{i}".to_sym)
            end
          end
          address_array << postCode if respond_to?(:postCode)
          address_array
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.21.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.19.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.18.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.17.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.16.4 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.16.3 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.16.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.16.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.15.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.14.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.14.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.13.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.12.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.12.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.11.0 lib/parliament/grom/decorator/postal_address.rb