Sha256: f4d8dcdf0ebffc0fa175e824a11eace3e2592003ec140204843f74ded56043a0

Contents?: true

Size: 1.02 KB

Versions: 39

Compression:

Stored size: 1.02 KB

Contents

module Ddr::Models
  class MetadataVocabulary
    extend MetadataVocabularies

    attr_reader :rdf_vocab, :except, :only_properties

    # @param rdf_vocab [RDF::Vocabulary] an RDF vocabulary class
    # @param except [RDF::Vocabulary::Term, Array<RDF::Vocabulary::Term>] term(s) to exclude
    # @param only_properties [Boolean] whether to include only RDF properties
    #   -- i.e., having RDF type http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
    #   -- default: true
    def initialize(rdf_vocab, except: nil, only_properties: true)
      @rdf_vocab = rdf_vocab
      @except = Array(except)
      @only_properties = only_properties
    end

    # @return [Array<RDF::Vocabulary::Term>]
    def terms
      @terms ||= rdf_properties.map { |term| MetadataTerm.new(term) }
    end

    private

    def rdf_properties
      props = rdf_vocab.properties
      if only_properties
        props.select! { |prop| prop.type.include?("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") }
      end
      props - except
    end

  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ddr-models-3.0.8 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.7 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.6 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.5 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.4 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.3 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.2 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.1 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc6 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc5 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc4 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc3 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc2 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.rc1 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.beta.22 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.beta.21 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.beta.20 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.beta.18 lib/ddr/models/metadata/metadata_vocabulary.rb
ddr-models-3.0.0.beta.17 lib/ddr/models/metadata/metadata_vocabulary.rb