Class: OfflineSort::Sorter

Inherits:
Object
  • Object
show all
Defined in:
lib/offline_sort/offline_sort.rb

Defined Under Namespace

Classes: ChunkEntry

Constant Summary collapse

DEFAULT_CHUNK_IO_CLASS =
defined?(::MessagePack) ? Chunk::InputOutput::MessagePack : Chunk::InputOutput::Marshal
DEFAULT_CHUNK_SIZE =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enumerable, chunk_input_output_class: DEFAULT_CHUNK_IO_CLASS, chunk_size: DEFAULT_CHUNK_SIZE, &sort_by) ⇒ Sorter

Returns a new instance of Sorter.



15
16
17
18
19
20
# File 'lib/offline_sort/offline_sort.rb', line 15

def initialize(enumerable, chunk_input_output_class: DEFAULT_CHUNK_IO_CLASS, chunk_size: DEFAULT_CHUNK_SIZE, &sort_by)
  @enumerable = enumerable
  @chunk_input_output_class = chunk_input_output_class
  @chunk_size = chunk_size
  @sort_by = sort_by
end

Instance Attribute Details

#chunk_input_output_classObject (readonly)

Returns the value of attribute chunk_input_output_class.



13
14
15
# File 'lib/offline_sort/offline_sort.rb', line 13

def chunk_input_output_class
  @chunk_input_output_class
end

#chunk_sizeObject (readonly)

Returns the value of attribute chunk_size.



13
14
15
# File 'lib/offline_sort/offline_sort.rb', line 13

def chunk_size
  @chunk_size
end

#enumerableObject (readonly)

Returns the value of attribute enumerable.



13
14
15
# File 'lib/offline_sort/offline_sort.rb', line 13

def enumerable
  @enumerable
end

#sort_byObject (readonly)

Returns the value of attribute sort_by.



13
14
15
# File 'lib/offline_sort/offline_sort.rb', line 13

def sort_by
  @sort_by
end

Instance Method Details

#sortObject



22
23
24
# File 'lib/offline_sort/offline_sort.rb', line 22

def sort
  merge(split)
end