Module: Merritt::Manifest::Field::ClassMethods

Included in:
Merritt::Manifest::Fields::Object
Defined in:
lib/merritt/manifest/fields.rb

Overview

Class methods for field enumerations

Instance Method Summary collapse

Instance Method Details

#fieldsString

A list of all fields

Returns:

  • (String)

    a list of all fields, as (prefix-qualified) names



51
52
53
# File 'lib/merritt/manifest/fields.rb', line 51

def fields
  @fields ||= to_a.map(&:value).freeze
end

#prefixesHash<Symbol, String>

Gets all prefixes in these fields, and their URLs

Returns:

  • (Hash<Symbol, String>)

    all prefixes used by these fields, as a map from symbol to URL string



42
43
44
45
46
47
# File 'lib/merritt/manifest/fields.rb', line 42

def prefixes
  @prefixes ||= begin
    all_prefixes = to_a.map(&:prefix).uniq.sort.freeze
    all_prefixes.map { |p| [p, url_for(p)] }.to_h.freeze
  end
end

#url_for(prefix) ⇒ String

Gets the string for the specified prefix

Parameters:

  • prefix (String, Symbol)

    the prefix

Returns:

  • (String)

    the URL string for the prefix



58
59
60
61
62
63
64
65
66
# File 'lib/merritt/manifest/fields.rb', line 58

def url_for(prefix)
  # noinspection RubyCaseWithoutElseBlockInspection
  case prefix.to_sym
  when :mrt
    'http://merritt.cdlib.org/terms#'
  when :nfo
    'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#'
  end
end