Module: ClosestNeighbours
- Defined in:
- lib/closest_neighbours.rb,
lib/closest_neighbours/grouper.rb,
lib/closest_neighbours/indexer.rb,
lib/closest_neighbours/version.rb,
lib/closest_neighbours/orderers/sorted_order.rb,
lib/closest_neighbours/orderers/default_order.rb,
lib/closest_neighbours/errors/non_integer_groups_error.rb,
lib/closest_neighbours/errors/insufficient_groups_error.rb,
lib/closest_neighbours/errors/incomparable_element_error.rb,
lib/closest_neighbours/errors/non_enumberable_argument_error.rb
Overview
Top level model for Closest Neighbours gem
Defined Under Namespace
Classes: DefaultOrder, Grouper, IncomparableElementError, Indexer, InsufficientGroupsError, NonEnumberableArgumentError, NonIntegerGroupsError, SortedOrder
Constant Summary collapse
- VERSION =
'0.2.1'.freeze
Class Method Summary collapse
-
.group(groups, data) ⇒ Array
Split an Enumerable into specified number of groups containing the closest elements in each group using the most general purpose algorithm.
-
.ordered_group(groups, ordered_data) ⇒ Array
Split a sorted Enumerable into specified number of groups containing the closest elements in each group.
Class Method Details
.group(groups, data) ⇒ Array
Split an Enumerable into specified number of groups containing the closest elements in each group using the most general purpose algorithm.
31 32 33 |
# File 'lib/closest_neighbours.rb', line 31 def self.group(groups, data) Grouper.new(orderer: SortedOrder.new).call(groups, data) end |
.ordered_group(groups, ordered_data) ⇒ Array
Split a sorted Enumerable into specified number of groups containing the closest elements in each group.
48 49 50 |
# File 'lib/closest_neighbours.rb', line 48 def self.ordered_group(groups, ordered_data) Grouper.new(orderer: DefaultOrder.new).call(groups, ordered_data) end |