Class: Cocina::Models::Mapping::FromMods::AltRepGroup
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::FromMods::AltRepGroup
- Defined in:
- lib/cocina/models/mapping/from_mods/alt_rep_group.rb
Overview
Helper class: splits nodes by altRepGroup ids
Class Method Summary collapse
-
.split(nodes:) ⇒ Array<Array<Nokogiri::XML::Element>>, Array<Nokogiri::XML::Element>
Nodes grouped by altRepGroup, other nodes.
Class Method Details
.split(nodes:) ⇒ Array<Array<Nokogiri::XML::Element>>, Array<Nokogiri::XML::Element>
Returns nodes grouped by altRepGroup, other nodes.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cocina/models/mapping/from_mods/alt_rep_group.rb', line 11 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 |