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) ⇒ Boolean
The comparison operator.
-
#completed? ⇒ Boolean
Whether the status is completed.
-
#eql?(other) ⇒ Boolean
Whether objects are identical to each other.
-
#hash ⇒ Fixnum
Generate a hash value for this object.
-
#initialize(state:, **_) ⇒ Status
constructor
A new instance of Status.
-
#method_missing(method_name, *arguments, &block) ⇒ Boolean
Determine whether this method corresponds to a status check for a valid state.
-
#queued? ⇒ Boolean
Whether the status is queued.
-
#queued_held? ⇒ Boolean
Whether the status is queued_held.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Determines whether this method corresponds to a status check for a valid state.
-
#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.
43 44 45 46 |
# File 'lib/ood_core/job/status.rb', line 43 def initialize(state:, **_) @state = state.to_sym raise UnknownStateAttribute, "arguments specify unknown '#{@state}' state" unless self.class.states.include?(@state) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Boolean
Determine whether this method corresponds to a status check for a valid state. If so, then check whether this object is in that valid state.
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
Instance Attribute Details
#state ⇒ Symbol (readonly)
Current status of submitted job
39 40 41 |
# File 'lib/ood_core/job/status.rb', line 39 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
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ood_core/job/status.rb', line 25 def states %i( undetermined queued queued_held running suspended completed ) end |
Instance Method Details
#==(other) ⇒ Boolean
The comparison operator
63 64 65 |
# File 'lib/ood_core/job/status.rb', line 63 def ==(other) to_sym == other.to_sym end |
#completed? ⇒ Boolean
Whether the status is completed
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
#eql?(other) ⇒ Boolean
Whether objects are identical to each other
70 71 72 |
# File 'lib/ood_core/job/status.rb', line 70 def eql?(other) self.class == other.class && self == other end |
#hash ⇒ Fixnum
Generate a hash value for this object
76 77 78 |
# File 'lib/ood_core/job/status.rb', line 76 def hash [self.class, to_sym].hash end |
#queued? ⇒ Boolean
Whether the status is queued
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
#queued_held? ⇒ Boolean
Whether the status is queued_held
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Determines whether this method corresponds to a status check for a valid state
123 124 125 |
# File 'lib/ood_core/job/status.rb', line 123 def respond_to_missing?(method_name, include_private = false) /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) || super end |
#running? ⇒ Boolean
Whether the status is running
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
#suspended? ⇒ Boolean
Whether the status is suspended
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |
#to_s ⇒ String
Convert object to string
56 57 58 |
# File 'lib/ood_core/job/status.rb', line 56 def to_s state.to_s end |
#to_sym ⇒ Symbol
Convert object to symbol
50 51 52 |
# File 'lib/ood_core/job/status.rb', line 50 def to_sym state end |
#undetermined? ⇒ Boolean
Whether the status is undetermined
111 112 113 114 115 116 117 |
# File 'lib/ood_core/job/status.rb', line 111 def method_missing(method_name, *arguments, &block) if /^(?<other_state>.+)\?$/ =~ method_name && self.class.states.include?(other_state.to_sym) self == other_state else super end end |