Class: Glossarist::LocalizedConcept

Inherits:
Concept show all
Defined in:
lib/glossarist/localized_concept.rb

Instance Attribute Summary collapse

Attributes inherited from Concept

#dates, #definition, #designations, #domain, #examples, #extension_attributes, #id, #lineage_source, #lineage_source_similarity, #non_verb_rep, #notes, #release, #sources, #subject, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Concept

#authoritative_source, #authoritative_source=, #date_accepted, #date_accepted=, #initialize, #normalize_args, #preferred_designations, #related, #related=, #to_h

Methods inherited from Model

#initialize, new, #set_attribute, #snake_case

Constructor Details

This class inherits a constructor from Glossarist::Concept

Instance Attribute Details

#classificationString

TODO:

Proper type checking.

Note:

Works with strings, but soon they may be replaced with symbols.

Must be one of the following: preferred, admitted, deprecated.

Returns:

  • (String)


26
27
28
# File 'lib/glossarist/localized_concept.rb', line 26

def classification
  @classification
end

#entry_statusString

TODO:

Proper type checking.

Note:

Works with strings, but soon they may be replaced with symbols.

Must be one of the following: notValid, valid, superseded, retired.

Returns:

  • (String)


18
19
20
# File 'lib/glossarist/localized_concept.rb', line 18

def entry_status
  @entry_status
end

#language_codeString

ISO 639-2 code for terminology.

Returns:

  • (String)

See Also:



11
12
13
# File 'lib/glossarist/localized_concept.rb', line 11

def language_code
  @language_code
end

Class Method Details

.from_h(hash) ⇒ Object



64
65
66
67
68
69
# File 'lib/glossarist/localized_concept.rb', line 64

def self.from_h(hash)
  terms = hash["terms"]&.map { |h| Designation::Base.from_h(h) } || []
  sources = hash["authoritative_source"]&.each { |source| source.merge({ "type" => "authoritative" }) }

  super(hash.merge({ "terms" => terms, "sources" => sources }))
end

Instance Method Details

#to_h_no_uuidObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/glossarist/localized_concept.rb', line 45

def to_h_no_uuid # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  hash = super

  hash["data"].merge!({
    "language_code" => language_code,
    "entry_status" => entry_status,
    "sources" => sources.empty? ? nil : sources&.map(&:to_h),
    "classification" => classification,
    "dates" => dates&.map(&:to_h),
    "review_date" => review_date,
    "review_decision_date" => review_decision_date,
    "review_decision_event" => review_decision_event,
  }.compact).merge!(@extension_attributes)

  hash["status"] = entry_status if entry_status

  hash
end