class Ddr::Models::MetadataVocabulary

Attributes

except[R]
only_properties[R]
rdf_vocab[R]

Public Class Methods

new(rdf_vocab, except: nil, only_properties: true) click to toggle source

@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
# File lib/ddr/models/metadata/metadata_vocabulary.rb, line 12
def initialize(rdf_vocab, except: nil, only_properties: true)
  @rdf_vocab = rdf_vocab
  @except = Array(except)
  @only_properties = only_properties
end

Public Instance Methods

terms() click to toggle source

@return [Array<RDF::Vocabulary::Term>]

# File lib/ddr/models/metadata/metadata_vocabulary.rb, line 19
def terms
  @terms ||= rdf_properties.map { |term| MetadataTerm.new(term) }
end

Private Instance Methods

rdf_properties() click to toggle source
# File lib/ddr/models/metadata/metadata_vocabulary.rb, line 25
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