Class: OodCore::Job::Status
- Inherits:
-
Object
- Object
- OodCore::Job::Status
- Defined in:
- lib/ood_core/job/status.rb
Overview
An object that describes the current state of a submitted job.
Instance Attribute Summary collapse
-
#state ⇒ Symbol
readonly
Current status of submitted job.
Class Method Summary collapse
-
.states ⇒ Object
Possible states a submitted job can be in: # Job status cannot be determined :undetermined.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
The comparison operator for sorting values.
-
#==(other) ⇒ Boolean
The comparison operator.
-
#completed? ⇒ Boolean
Whether the status is completed.
-
#eql?(other) ⇒ Boolean
Whether objects are identical to each other.
-
#hash ⇒ Integer
Generate a hash value for this object.
-
#initialize(state:, **_) ⇒ Status
constructor
A new instance of Status.
- #precedence ⇒ Object
-
#queued? ⇒ Boolean
Whether the status is queued.
-
#queued_held? ⇒ Boolean
Whether the status is queued_held.
-
#running? ⇒ Boolean
Whether the status is running.
-
#suspended? ⇒ Boolean
Whether the status is suspended.
-
#to_s ⇒ String
Convert object to string.
-
#to_sym ⇒ Symbol
Convert object to symbol.
-
#undetermined? ⇒ Boolean
Whether the status is undetermined.
Constructor Details
#initialize(state:, **_) ⇒ Status
Returns a new instance of Status.
45 46 47 48 |
# 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 |
Instance Attribute Details
#state ⇒ Symbol (readonly)
Current status of submitted job
41 42 43 |
# File 'lib/ood_core/job/status.rb', line 41 def state @state end |
Class Method Details
.states ⇒ Object
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
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ood_core/job/status.rb', line 27 def states %i( undetermined completed queued_held queued running suspended ) end |
Instance Method Details
#<=>(other) ⇒ Integer
The comparison operator for sorting values.
126 127 128 |
# File 'lib/ood_core/job/status.rb', line 126 def <=>(other) precedence <=> other.precedence end |
#==(other) ⇒ Boolean
The comparison operator
65 66 67 |
# File 'lib/ood_core/job/status.rb', line 65 def ==(other) to_sym == other.to_sym end |
#completed? ⇒ Boolean
Whether the status is completed
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |
#eql?(other) ⇒ Boolean
Whether objects are identical to each other
72 73 74 |
# File 'lib/ood_core/job/status.rb', line 72 def eql?(other) self.class == other.class && self == other end |
#hash ⇒ Integer
Generate a hash value for this object
78 79 80 |
# File 'lib/ood_core/job/status.rb', line 78 def hash [self.class, to_sym].hash end |
#precedence ⇒ Object
119 120 121 |
# File 'lib/ood_core/job/status.rb', line 119 def precedence self.class.states.index(@state) end |
#queued? ⇒ Boolean
Whether the status is queued
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |
#queued_held? ⇒ Boolean
Whether the status is queued_held
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |
#running? ⇒ Boolean
Whether the status is running
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |
#suspended? ⇒ Boolean
Whether the status is suspended
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |
#to_s ⇒ String
Convert object to string
58 59 60 |
# File 'lib/ood_core/job/status.rb', line 58 def to_s state.to_s end |
#to_sym ⇒ Symbol
Convert object to symbol
52 53 54 |
# File 'lib/ood_core/job/status.rb', line 52 def to_sym state end |
#undetermined? ⇒ Boolean
Whether the status is undetermined
113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 113 states.each do |state| define_method("#{state}?") do self == state end end |