Class: Omnizip::Parallel::JobQueue::Job

Inherits:
Struct
  • Object
show all
Defined in:
lib/omnizip/parallel/job_queue.rb

Overview

Job structure for queue items

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



19
20
21
# File 'lib/omnizip/parallel/job_queue.rb', line 19

def data
  @data
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



19
20
21
# File 'lib/omnizip/parallel/job_queue.rb', line 19

def file
  @file
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



19
20
21
# File 'lib/omnizip/parallel/job_queue.rb', line 19

def 
  @metadata
end

#priorityObject

Returns the value of attribute priority

Returns:

  • (Object)

    the current value of priority



19
20
21
# File 'lib/omnizip/parallel/job_queue.rb', line 19

def priority
  @priority
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



19
20
21
# File 'lib/omnizip/parallel/job_queue.rb', line 19

def size
  @size
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/omnizip/parallel/job_queue.rb', line 21

def <=>(other)
  # Higher priority first, then larger files first
  priority_order = { high: 0, normal: 1, low: 2 }
  priority_cmp = (priority_order[priority] || 1) <=> (priority_order[other.priority] || 1)
  return priority_cmp unless priority_cmp.zero?

  # If same priority, larger files first
  -(size <=> other.size)
end