Class: SduSmart::Taxonomy::Concept

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/sdu_smart/taxonomy/concept.rb

Class Method Summary collapse

Class Method Details

.fetch(label) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/sdu_smart/taxonomy/concept.rb', line 26

def fetch(label)
  unless self::VALUES.include?(label)
    raise ArgumentError, "#{name}: invalid value '#{label}'. Valid: #{self::VALUES.join(', ')}"
  end

  new(label: label)
end

.taxonomy(rdf_type, values:, subject_path:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sdu_smart/taxonomy/concept.rb', line 9

def taxonomy(rdf_type, values:, subject_path:)
  const_set(:VALUES, values.freeze)

  rdf do
    namespace SduSmart::Rdf::Namespaces::SmartNamespace,
              Lutaml::Rdf::Namespaces::SkosNamespace

    subject { |m| "https://w3id.org/standards/smart/taxonomies/#{subject_path}/#{m.label}" }

    type "smart:#{rdf_type}"

    predicate :prefLabel,
              namespace: Lutaml::Rdf::Namespaces::SkosNamespace,
              to: :label
  end
end