Sha256: fb62ddec1b65ffa61639ab4fb23a862e821166615068fcf6af7b2aa770047816

Contents?: true

Size: 1 KB

Versions: 40

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Cocina
  module Models
    module Mapping
      module FromMods
        # Maps lang and script attributes
        class LanguageScript
          # @param [Nokogiri::XML::Element] element that may have lang or script attributes
          # @param [Cocina::Models::Mapping::FromMods::DescriptionBuilder] description_builder
          # @return [Hash] a hash that can be mapped to a cocina model for a valueLanguage
          def self.build(node:)
            return nil unless node['lang'].present? || node['script'].present?

            {}.tap do |value_language|
              if node['lang'].present?
                value_language[:code] = node['lang']
                value_language[:source] = { code: 'iso639-2b' }
              end
              if node['script'].present?
                value_language[:valueScript] =
                  { code: node['script'], source: { code: 'iso15924' } }
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
cocina-models-0.99.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.99.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.98.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.98.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.96.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.95.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.95.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.94.2 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.94.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.94.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.93.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.93.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.92.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.91.4 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.91.3 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.91.2 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.91.1 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.91.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.90.0 lib/cocina/models/mapping/from_mods/language_script.rb
cocina-models-0.89.1 lib/cocina/models/mapping/from_mods/language_script.rb