Sha256: a0441a915542c9ccc706e20e2539c24d15d6551c1cbc2714abce99b121cbbd48
Contents?: true
Size: 1.69 KB
Versions: 4
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true require_relative "entry_term" require_relative "textual_support" module Termium # For <languageModule> class LanguageModule < Shale::Mapper attribute :language, Shale::Type::String attribute :entry_term, EntryTerm, collection: true attribute :textual_support, TextualSupport, collection: true xml do root "languageModule" map_attribute "language", to: :language map_element "entryTerm", to: :entry_term map_element "textualSupport", to: :textual_support end def definition_raw textual_support.detect(&:is_definition?) end def definition definition_raw&.value_typed end def domain definition_raw&.domain end def notes textual_support.select(&:is_note?).map(&:value_typed) end def examples textual_support.select(&:is_example?).map(&:value_typed) end def abbreviations entry_term.map(&:abbreviation).flatten end LANGUAGE_CODE_MAPPING = { "en" => "eng", "fr" => "fre" }.freeze def designations # NOTE: entry_term is a collection entry_term + abbreviations end def to_h # TODO: This is needed to skip the empty french entries of 10031781 and 10031778 return nil unless definition src = { "language_code" => LANGUAGE_CODE_MAPPING[language.downcase], "terms" => designations.map(&:to_h), "definition" => [{ content: definition }], "notes" => notes, "examples" => examples } src["domain"] = domain if domain src end def to_concept x = to_h return nil unless x Glossarist::LocalizedConcept.new(x) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
termium-0.1.4 | lib/termium/language_module.rb |
termium-0.1.2 | lib/termium/language_module.rb |
termium-0.1.1 | lib/termium/language_module.rb |
termium-0.1.0 | lib/termium/language_module.rb |