Class: OodCore::Job::NodeInfo
- Inherits:
-
Object
- Object
- OodCore::Job::NodeInfo
- Defined in:
- lib/ood_core/job/node_info.rb
Overview
An object that describes the resources used on a specific node.
Instance Attribute Summary collapse
-
#features ⇒ Array<String>, []
readonly
The features associated with this node.
-
#name ⇒ String
readonly
The name of the host machine.
-
#procs ⇒ Integer?
readonly
The number of procs reserved on the given machine.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
The comparison operator.
-
#eql?(other) ⇒ Boolean
Whether objects are identical to each other.
-
#hash ⇒ Integer
Generate a hash value for this object.
-
#initialize(name:, procs: nil, features: [], **_) ⇒ NodeInfo
constructor
A new instance of NodeInfo.
-
#to_h ⇒ Hash
Convert object to hash.
Constructor Details
#initialize(name:, procs: nil, features: [], **_) ⇒ NodeInfo
Returns a new instance of NodeInfo.
20 21 22 23 24 |
# File 'lib/ood_core/job/node_info.rb', line 20 def initialize(name:, procs: nil, features: [], **_) @name = name.to_s @procs = procs && procs.to_i @features = features.to_a end |
Instance Attribute Details
#features ⇒ Array<String>, [] (readonly)
The features associated with this node.
15 16 17 |
# File 'lib/ood_core/job/node_info.rb', line 15 def features @features end |
#name ⇒ String (readonly)
The name of the host machine
7 8 9 |
# File 'lib/ood_core/job/node_info.rb', line 7 def name @name end |
#procs ⇒ Integer? (readonly)
The number of procs reserved on the given machine
11 12 13 |
# File 'lib/ood_core/job/node_info.rb', line 11 def procs @procs end |
Instance Method Details
#==(other) ⇒ Boolean
The comparison operator
38 39 40 |
# File 'lib/ood_core/job/node_info.rb', line 38 def ==(other) to_h == other.to_h end |
#eql?(other) ⇒ Boolean
Whether objects are identical to each other
45 46 47 |
# File 'lib/ood_core/job/node_info.rb', line 45 def eql?(other) self.class == other.class && self == other end |
#hash ⇒ Integer
Generate a hash value for this object
51 52 53 |
# File 'lib/ood_core/job/node_info.rb', line 51 def hash [self.class, to_h].hash end |
#to_h ⇒ Hash
Convert object to hash
28 29 30 31 32 33 |
# File 'lib/ood_core/job/node_info.rb', line 28 def to_h instance_variables.map do |var| name = var.to_s.gsub('@', '').to_sym [name, send(name)] end.to_h end |