Class: OodCore::Job::NodeInfo

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(name:, procs: nil, features: [], **_) ⇒ 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

#featuresArray<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

#nameString (readonly)

The name of the host machine



7
8
9
# File 'lib/ood_core/job/node_info.rb', line 7

def name
  @name
end

#procsInteger? (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

#hashInteger

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_hHash

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