class OodReservations::Reservation::Node

Object that describes a reserved node on a generic batch server FIXME: This should be generalized in some other gem

Attributes

id[R]

The id of the node @return [String] id of node

jobs[R]

A list of jobs running on this node @return [Array<String>] list of jobs running on node

ppn[R]

The number of cores on this node @return [Fixnum] number of cores

ppn_used[R]

The number of cores used on this node @return [Fixnum] number of cores used

props[R]

A list of properties describing this node @return [Array<Symbol>] list of properties

Public Class Methods

new(id:, ppn:, ppn_used:, props:, jobs:) click to toggle source

@param id [#to_s] id of node @param ppn [#to_i] number of cores @param ppn_used [#to_i] number of used cores @param props [Array<#to_sym>] list of properties of node @param jobs [Array<#to_s>] list of jobs on node

# File lib/ood_reservations/reservation.rb, line 123
def initialize(id:, ppn:, ppn_used:, props:, jobs:)
  @id       = id.to_s
  @ppn      = ppn.to_i
  @ppn_used = ppn_used.to_i
  @props    = props.map(&:to_sym)
  @jobs     = jobs.map(&:to_s)
end

Public Instance Methods

<=>(other) click to toggle source

The comparison operator for sorting values @param other [#to_s] object to compare against @return [Boolean] how objects compare

# File lib/ood_reservations/reservation.rb, line 146
def <=>(other)
  to_s <=> other.to_s
end
eql?(other) click to toggle source

Check whether objects are identical to each other @param other [#to_h] object to compare against @return [Boolean] whether objects are identical

# File lib/ood_reservations/reservation.rb, line 153
def eql?(other)
  self.class == other.class && self == other
end
hash() click to toggle source

Generate a hash value for this object @return [Fixnum] hash value of object

# File lib/ood_reservations/reservation.rb, line 159
def hash
  [self.class, to_s].hash
end
is_free?() click to toggle source

Is this node free to be used? @return [Boolean] free to use?

# File lib/ood_reservations/reservation.rb, line 133
def is_free?
  ppn_used == 0
end
to_s() click to toggle source

Convert object to string @return [String] the string describing this object

# File lib/ood_reservations/reservation.rb, line 139
def to_s
  id
end