Class: Parliament::Utils::Helpers::BusinessItemGroupingHelper

Inherits:
Object
  • Object
show all
Extended by:
GroupingHelper
Defined in:
lib/parliament/utils/helpers/business_item_grouping_helper.rb

Defined Under Namespace

Classes: BusinessItemGroupedObject

Class Method Summary collapse

Methods included from GroupingHelper

create_sorted_array, group, group_data

Class Method Details

.create_grouped_objects(data_hash, key) ⇒ Array

Creates new BusinessItemGroupingHelper::BusinessItemGroupedObject, for each set of Grom::Nodes that have been grouped (nodes) and unknown Each instance of BusinessItemGroupingHelper::BusinessItemGroupedObject is assigned properties of laying_date, nodes and type

Parameters:

  • data_hash (Hash)

    Keys identify grouping, with each value being an array of grouped, ungrouped and unknown Grom::Nodes

  • key (String)

    Key identifies grouping of Grom::Nodes

Returns:

  • (Array)

    with instances of GroupingHelper::GroupedObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/parliament/utils/helpers/business_item_grouping_helper.rb', line 21

def self.create_grouped_objects(data_hash, key)
  grouped = []

  grouped_object = BusinessItemGroupingHelper::BusinessItemGroupedObject.new
  grouped_object.nodes = data_hash[key].sort_by(&:shortest_distance_of_procedure_steps)

  # Set properties of the object
  grouped_object.type = grouped_object.nodes.first.type
  grouped_object.date = grouped_object.nodes.first.date
  grouped << grouped_object
end