Class: Catalog::Inventory
Instance Attribute Summary
Attributes inherited from Catalog
Instance Method Summary collapse
- #build ⇒ Object
-
#citations_summary ⇒ Array of Hash
Each hash represents a unique (type, source) pair with topics unioned across all items of that type from that source.
Methods inherited from Catalog
all_dates, chronological_item_sort, #citations, #entries_sorted, #entry_sort_valid?, #initialize, #items, #items_chronologically, #objects_for_source, #reference_object_global_id, #reference_object_valid_taxon_name_global_id, #sources, #sources_to_json, topic_year_metadata, #topics, #topics_to_json, year_hash, year_metadata
Constructor Details
This class inherits a constructor from Catalog
Instance Method Details
#build ⇒ Object
3 4 5 6 7 8 |
# File 'lib/catalog/inventory.rb', line 3 def build catalog_targets.each do |t| @entries.push(Catalog::Otu::InventoryEntry.new(t)) end true end |
#citations_summary ⇒ Array of Hash
Returns Each hash represents a unique (type, source) pair with topics unioned across all items of that type from that source.
- { type: String, source: Source, topics: [Topic
-
}, … ].
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/catalog/inventory.rb', line 14 def citations_summary items.group_by { |item| [item.object.class.name, item.citation&.source_id] } .map do |(type, _source_id), grouped_items| { type: type, source: grouped_items.first.citation&.source, topics: grouped_items.flat_map(&:topics).uniq } end end |