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, #non_verb_rep, #notes, #sources, #subject

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Concept

#authoritative_source=, #related, #related=

Methods inherited from Model

new, #set_attribute

Constructor Details

#initializeLocalizedConcept

Returns a new instance of LocalizedConcept.



31
32
33
34
35
# File 'lib/glossarist/localized_concept.rb', line 31

def initialize(*)
  @examples = []

  super
end

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)


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

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

#review_dateObject

Returns the value of attribute review_date.



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

def review_date
  @review_date
end

#review_decision_dateObject

Returns the value of attribute review_decision_date.



28
29
30
# File 'lib/glossarist/localized_concept.rb', line 28

def review_decision_date
  @review_decision_date
end

#review_decision_eventObject

Returns the value of attribute review_decision_event.



29
30
31
# File 'lib/glossarist/localized_concept.rb', line 29

def review_decision_event
  @review_decision_event
end

Class Method Details

.from_h(hash) ⇒ Object



50
51
52
53
54
55
# File 'lib/glossarist/localized_concept.rb', line 50

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_hObject Also known as: to_hash

rubocop:disable Metrics/MethodLength



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/glossarist/localized_concept.rb', line 37

def to_h # rubocop:disable Metrics/MethodLength
  super.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)
end