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, **_) ⇒ NodeInfo

Returns a new instance of NodeInfo

Parameters:

  • name (#to_s)

    node name

  • procs (#to_i, nil)

    number of procs


15
16
17
18
# File 'lib/ood_core/job/node_info.rb', line 15

def initialize(name:, procs: nil, **_)
  @name  = name.to_s
  @procs = procs && procs.to_i
end

Instance Attribute Details

#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

#procsFixnum? (readonly)

The number of procs reserved on the given machine

Returns:

  • (Fixnum, 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


29
30
31
# File 'lib/ood_core/job/node_info.rb', line 29

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


36
37
38
# File 'lib/ood_core/job/node_info.rb', line 36

def eql?(other)
  self.class == other.class && self == other
end

#hashFixnum

Generate a hash value for this object

Returns:

  • (Fixnum)

    hash value of object


42
43
44
# File 'lib/ood_core/job/node_info.rb', line 42

def hash
  [self.class, to_h].hash
end

#to_hHash

Convert object to hash

Returns:

  • (Hash)

    object as hash


22
23
24
# File 'lib/ood_core/job/node_info.rb', line 22

def to_h
  { name: name, procs: procs }
end