Module: StateGeoTools::Toploader

Included in:
StateGeoTools
Defined in:
lib/state_geo_tools/toploader.rb

Overview

Sometimes you want to pull some entries up.

Defined Under Namespace

Classes: NotInSetError

Constant Summary collapse

TOPLOAD_ERROR =
'is not in the set and not toploadable'

Instance Method Summary collapse

Instance Method Details

#topload_items(set, topload) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/state_geo_tools/toploader.rb', line 10

def topload_items(set, topload)
  topload.each do |x|
    raise(NotInSetError, "#{x} #{TOPLOAD_ERROR}") unless set.include?(x)
  end

  # If not in the topload set, offset the ordering by a few hundred so it
  # maintains its current order
  set.sort_by { |item| topload.index(item) || (500 + set.index(item)) }
end