module Paf::ThoroughfareLocality

Processing for thoroughfare and locality elements of a PAF entry

Public Instance Methods

thoroughfares_and_localities() click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 4
def thoroughfares_and_localities
  [].tap do |array|
    thoroughfare_and_locality_attrs.each do |attr|
      array << send(attr) unless used_or_vacant?(attr)
    end
  end
end

Private Instance Methods

first_thoroughfare_or_locality() click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 18
def first_thoroughfare_or_locality
  send(first_thoroughfare_or_locality_attr) unless
    first_thoroughfare_or_locality_attr.nil?
end
first_thoroughfare_or_locality_attr() click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 23
def first_thoroughfare_or_locality_attr
  thoroughfare_and_locality_attrs.find { |attr| !send(attr).vacant? }
end
thoroughfare_and_locality_attrs() click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 14
def thoroughfare_and_locality_attrs
  %i[dependent_thoroughfare thoroughfare] + self.class.locality_attrs
end
used?(attr) click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 27
def used?(attr)
  premises_includes_first_thoroughfare_or_locality? &&
    (attr == first_thoroughfare_or_locality_attr)
end
used_or_vacant?(attr) click to toggle source
# File lib/paf/thoroughfare_locality.rb, line 32
def used_or_vacant?(attr)
  used?(attr) || send(attr).vacant?
end