Sha256: cb8c137a363e27a93f55e8ec71ddbc722c9b9bd7c4b2fe79a2bf06e333bfe1a9

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# encoding: UTF-8
require 'locabulary/exceptions'
require 'locabulary/items/base'

module Locabulary
  module Items
    # Responsible for exposing the data structure logic of the Administrative Units
    #
    # @see ./data/administrative_units.json
    class AdministrativeUnit < Locabulary::Items::Base
      configure do |config|
        config.attribute_names = [
          :predicate_name, :term_label, :term_uri, :description, :grouping, :classification, :affiliation, :default_presentation_sequence,
          :homepage, :activated_on, :deactivated_on
        ]
      end

      # [String] What is the URL of the homepage. Please note the term_uri is reserved for something that is more resolvable by machines.
      #   And while the homepage may look resolvable, it is not as meaningful for longterm preservation.
      attr_reader :homepage
      attr_reader :classification
      attr_reader :grouping
      attr_reader :affiliation

      private

      attr_writer :homepage, :classification, :grouping, :affiliation

      public

      NON_DEPARTMENTAL_SLUG = "Non-Departmental".freeze
      # NOTE: The whitespace characters are "thin spaces", U+200A
      HUMAN_FRIENDLY_HIERARCHY_DELIMITER = ' — '.freeze
      def selectable_label
        if slugs[-1] == NON_DEPARTMENTAL_SLUG
          slugs[-2..-1].join(HUMAN_FRIENDLY_HIERARCHY_DELIMITER)
        else
          slugs[-1]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locabulary-0.6.1 lib/locabulary/items/administrative_unit.rb
locabulary-0.6.0 lib/locabulary/items/administrative_unit.rb
locabulary-0.5.1 lib/locabulary/items/administrative_unit.rb
locabulary-0.5.0 lib/locabulary/items/administrative_unit.rb