Class: ClosestNeighbours::Grouper::GrouperHelper
- Inherits:
-
Object
- Object
- ClosestNeighbours::Grouper::GrouperHelper
- Defined in:
- lib/closest_neighbours/grouper.rb
Overview
Helper class to index data and extract ranges from an enumberble
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(groups, data) ⇒ GrouperHelper
constructor
A new instance of GrouperHelper.
Constructor Details
#initialize(groups, data) ⇒ GrouperHelper
Returns a new instance of GrouperHelper.
27 28 29 30 |
# File 'lib/closest_neighbours/grouper.rb', line 27 def initialize(groups, data) @groups = groups @data = data end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/closest_neighbours/grouper.rb', line 32 def call if groups == 1 [data] elsif groups >= data.count cells + blanks else ranges.map { |range| data[range] } end end |