class OodCore::Job::Status

An object that describes the current state of a submitted job

Attributes

state[R]

Current status of submitted job @return [Symbol] status of job

Public Class Methods

new(state:, **_) click to toggle source

@param state [#to_sym] status of job @raise [UnknownStateAttribute] if supplied state does not exist

# File lib/ood_core/job/status.rb, line 45
def initialize(state:, **_)
  @state = state.to_sym
  raise UnknownStateAttribute, "arguments specify unknown '#{@state}' state" unless self.class.states.include?(@state)
end
states() click to toggle source

Possible states a submitted job can be in:

# Job status cannot be determined
:undetermined

# Job is queued for being scheduled and executed
:queued

# Job has been placed on hold by the system, the administrator, or
# submitting user
:queued_held

# Job is running on an execution host
:running

# Job has been suspended by the user, the system, or the administrator
:suspended

# Job is completed and not running on an execution host
:completed

@note that this list's order is meaningful and should not be sorted lexigraphically
# File lib/ood_core/job/status.rb, line 27
def states
  %i(
    undetermined
    completed
    queued_held
    queued
    running
    suspended
  )
end

Public Instance Methods

<=>(other) click to toggle source

The comparison operator for sorting values.

@return [Integer] Comparison value based on precedence

# File lib/ood_core/job/status.rb, line 126
def <=>(other)
  precedence <=> other.precedence
end
==(other) click to toggle source

The comparison operator @param other [#to_sym] object to compare against @return [Boolean] whether objects are equivalent

# File lib/ood_core/job/status.rb, line 65
def ==(other)
  to_sym == other.to_sym
end
eql?(other) click to toggle source

Whether objects are identical to each other @param other [#to_sym] object to compare against @return [Boolean] whether objects are identical

# File lib/ood_core/job/status.rb, line 72
def eql?(other)
  self.class == other.class && self == other
end
hash() click to toggle source

Generate a hash value for this object @return [Integer] hash value of object

# File lib/ood_core/job/status.rb, line 78
def hash
  [self.class, to_sym].hash
end
precedence() click to toggle source
# File lib/ood_core/job/status.rb, line 119
def precedence
  self.class.states.index(@state)
end
to_s() click to toggle source

Convert object to string @return [String] object as string

# File lib/ood_core/job/status.rb, line 58
def to_s
  state.to_s
end
to_sym() click to toggle source

Convert object to symbol @return [Symbol] object as symbol

# File lib/ood_core/job/status.rb, line 52
def to_sym
  state
end