Class: OTB::Queue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string: nil) ⇒ Queue

Idea being you could also have string:nil then you could initialized with Job objects in the jobs: or you could initialized with String objects in the string:



9
10
11
12
# File 'lib/OTB/queue.rb', line 9

def initialize(string:nil)
 @jobs = string
 @jobs_parsed = OTB::Job.parse(@jobs) unless string.nil?
end

Instance Attribute Details

#jobsObject

Returns the value of attribute jobs.



3
4
5
# File 'lib/OTB/queue.rb', line 3

def jobs
  @jobs
end

#jobs_parsedObject

Returns the value of attribute jobs_parsed.



3
4
5
# File 'lib/OTB/queue.rb', line 3

def jobs_parsed
  @jobs_parsed
end

Instance Method Details

#sort_sequenceObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/OTB/queue.rb', line 14

def sort_sequence
  case @jobs
    when ''
      ''
    when nil
      raise JobQueueError.no_input_error
    else
      check_self_dependency(@jobs_parsed)
      check_circular_dependency(@jobs_parsed)
      sort_jobs_to_sequence(@jobs_parsed)
  end
end