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

Returns a new instance of NodeInfo.

Parameters:

  • name (#to_s)

    node name

  • procs (#to_i, nil) (defaults to: nil)

    number of procs

  • features (#to_a, []) (defaults to: [])

    list of features



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.

Returns:

  • (Array<String>, [])


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

Returns:

  • (String)

    node name



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

Returns:

  • (Integer, nil)

    number of procs



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

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are equivalent



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

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are identical



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

Returns:

  • (Integer)

    hash value of 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

Returns:

  • (Hash)

    object as 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