Class: Qa::Authorities::LinkedData::TermConfig
- Inherits:
-
Object
- Object
- Qa::Authorities::LinkedData::TermConfig
- Defined in:
- lib/qa/authorities/linked_data/config/term_config.rb
Instance Method Summary collapse
-
#initialize(config, prefixes = {}) ⇒ TermConfig
constructor
A new instance of TermConfig.
-
#supports_term? ⇒ True|False
Does this authority configuration have term defined?.
-
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?.
-
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?.
-
#term_language ⇒ Symbol
Return the preferred language for literal value selection for term fetch.
-
#term_qa_replacement_patterns ⇒ Hash
(also: #qa_replacement_patterns)
Return parameters that are required for QA api.
-
#term_results ⇒ Hash
Return results predicates.
-
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate.
-
#term_results_broader_predicate ⇒ String
Return results broader_predicate.
-
#term_results_id_predicate ⇒ String
Return results id_predicate.
-
#term_results_label_predicate ⇒ String
Return results label_predicate.
-
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate.
-
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate.
-
#term_subauthorities ⇒ Hash
(also: #subauthorities)
Return the list of subauthorities for term fetch.
-
#term_subauthorities? ⇒ True|False
Are there subauthorities configured for term fetch?.
-
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?.
-
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch.
-
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
Constructor Details
#initialize(config, prefixes = {}) ⇒ TermConfig
Returns a new instance of TermConfig.
9 10 11 12 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 9 def initialize(config, prefixes = {}) @term_config = config @prefixes = prefixes end |
Instance Method Details
#supports_term? ⇒ True|False
Does this authority configuration have term defined?
19 20 21 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 19 def supports_term? term_config.present? end |
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?
38 39 40 41 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 38 def term_id_expects_id? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "ID" end |
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?
31 32 33 34 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 31 def term_id_expects_uri? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "URI" end |
#term_language ⇒ Symbol
Return the preferred language for literal value selection for term fetch. Only applies if the authority provides language encoded literals.
45 46 47 48 49 50 51 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 45 def term_language return @term_language unless @term_language.nil? lang = Config.config_value(term_config, :language) return nil if lang.nil? lang = [lang] if lang.is_a? String @term_language = lang.collect(&:to_sym) end |
#term_qa_replacement_patterns ⇒ Hash Also known as: qa_replacement_patterns
Return parameters that are required for QA api
97 98 99 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 97 def term_qa_replacement_patterns Config.config_value(term_config, :qa_replacement_patterns) end |
#term_results ⇒ Hash
Return results predicates
55 56 57 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 55 def term_results Config.config_value(term_config, :results) end |
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate
73 74 75 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 73 def term_results_altlabel_predicate Config.predicate_uri(term_results, :altlabel_predicate) end |
#term_results_broader_predicate ⇒ String
Return results broader_predicate
79 80 81 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 79 def term_results_broader_predicate Config.predicate_uri(term_results, :broader_predicate) end |
#term_results_id_predicate ⇒ String
Return results id_predicate
61 62 63 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 61 def term_results_id_predicate Config.predicate_uri(term_results, :id_predicate) end |
#term_results_label_predicate ⇒ String
Return results label_predicate
67 68 69 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 67 def term_results_label_predicate Config.predicate_uri(term_results, :label_predicate) end |
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate
85 86 87 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 85 def term_results_narrower_predicate Config.predicate_uri(term_results, :narrower_predicate) end |
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate
91 92 93 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 91 def term_results_sameas_predicate Config.predicate_uri(term_results, :sameas_predicate) end |
#term_subauthorities ⇒ Hash Also known as:
Return the list of subauthorities for term fetch
123 124 125 126 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 123 def @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities) @term_subauthorities ||= term_config[:subauthorities] end |
#term_subauthorities? ⇒ True|False
Are there subauthorities configured for term fetch?
104 105 106 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 104 def .positive? end |
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?
110 111 112 113 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 110 def (subauth_name) subauth_name = subauth_name.to_sym if subauth_name.is_a? String .key? subauth_name end |
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch
117 118 119 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 117 def .size end |
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
25 26 27 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 25 def url_config @url_config ||= Qa::IriTemplate::UrlConfig.new(term_config[:url]) if supports_term? end |