Sha256: 8d92ceaba5530604f800c3669c5b2fbf6558c3baeba58309cc227edd55052f21

Contents?: true

Size: 804 Bytes

Versions: 23

Compression:

Stored size: 804 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|
            address_array << instance_variable_get("@addressLine#{i}".to_sym) if respond_to?("addressLine#{i}".to_sym)
          end
          address_array << postCode if respond_to?(:postCode)
          address_array
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.32.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.32.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.31.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.31.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.31.0.pre.rc lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.30.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.29.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.7 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.6 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.5 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.27.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.26.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.25.1 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.25.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.24.0 lib/parliament/grom/decorator/postal_address.rb
parliament-grom-decorators-0.23.0 lib/parliament/grom/decorator/postal_address.rb