Sha256: da813341dc431354ea90e29e0de1d9936b07057c4f62dac1dac3aea04c3f6dd5
Contents?: true
Size: 997 Bytes
Versions: 40
Compression:
Stored size: 997 Bytes
Contents
# frozen_string_literal: true module Cocina module Models module Mapping module FromMods # Helper class: splits nodes by altRepGroup ids class AltRepGroup # @param [Array<Nokogiri::XML::Element>] nodes to split # @return [Array<Array<Nokogiri::XML::Element>>, Array<Nokogiri::XML::Element>] nodes grouped by altRepGroup, other nodes def self.split(nodes:) all_nodes_with_altrepgroup = nodes.reject { |node| node[:altRepGroup].blank? } grouped_altrepgroup_nodes = all_nodes_with_altrepgroup .group_by { |node| node[:altRepGroup] } .values .reject { |group_nodes| group_nodes.size == 1 } other_nodes = nodes.reject { |node| grouped_altrepgroup_nodes.flatten.include?(node) } [grouped_altrepgroup_nodes, other_nodes] end end end end end end
Version data entries
40 entries across 40 versions & 1 rubygems