Method: RDF::Vocabulary.limit_vocabs

Defined in:
lib/rdf/vocabulary.rb

.limit_vocabs(*vocabs) ⇒ Array<RDF::Vocabulary>

Limits iteration over vocabularies to just those selected

Examples:

limit to set of vocabularies by symbol

RDF::Vocabulary.limit_vocabs(:rdf, :rdfs
RDF::Vocabulary.find_term('http://www.w3.org/2000/01/rdf-schema#Resource').pname
# => 'rdfs:Resource'

limit to set of vocabularies by class name

RDF::Vocabulary.limit_vocabs(RDF::RDFV, RDF::RDFS)
RDF::Vocabulary.find_term('http://www.w3.org/2000/01/rdf-schema#Resource').pname
# => 'rdfs:Resource'

Parameters:

  • vocabs (Array<symbol, RDF::Vocabulary>)

    A list of vocabularies (symbols or classes) which may be returned by each. Also limits vocabularies that will be inspeced for other methods. Set to nil, or an empty array to reset.

Returns:



179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/rdf/vocabulary.rb', line 179

def limit_vocabs(*vocabs)
  @vocabs = if Array(vocabs).empty?
    nil
  else
    vocabs.map do |vocab|
      vocab = :rdfv if vocab == :rdf
      vocab.is_a?(Symbol) && RDF::VOCABS.key?(vocab) ?
        RDF.const_get(RDF::VOCABS[vocab][:class_name].to_sym) :
        vocab
    end.compact
  end
end