Class: OodReservations::Reservation::Node
- Inherits:
-
Object
- Object
- OodReservations::Reservation::Node
- Includes:
- Comparable
- Defined in:
- lib/ood_reservations/reservation.rb
Overview
Object that describes a reserved node on a generic batch server FIXME: This should be generalized in some other gem
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The id of the node.
-
#jobs ⇒ Array<String>
readonly
A list of jobs running on this node.
-
#ppn ⇒ Fixnum
readonly
The number of cores on this node.
-
#ppn_used ⇒ Fixnum
readonly
The number of cores used on this node.
-
#props ⇒ Array<Symbol>
readonly
A list of properties describing this node.
Instance Method Summary collapse
-
#<=>(other) ⇒ Boolean
The comparison operator for sorting values.
-
#eql?(other) ⇒ Boolean
Check whether objects are identical to each other.
-
#hash ⇒ Fixnum
Generate a hash value for this object.
-
#initialize(id:, ppn:, ppn_used:, props:, jobs:) ⇒ Node
constructor
A new instance of Node.
-
#is_free? ⇒ Boolean
Is this node free to be used?.
-
#to_s ⇒ String
Convert object to string.
Constructor Details
#initialize(id:, ppn:, ppn_used:, props:, jobs:) ⇒ Node
Returns a new instance of Node.
123 124 125 126 127 128 129 |
# 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 |
Instance Attribute Details
#id ⇒ String (readonly)
The id of the node
100 101 102 |
# File 'lib/ood_reservations/reservation.rb', line 100 def id @id end |
#jobs ⇒ Array<String> (readonly)
A list of jobs running on this node
116 117 118 |
# File 'lib/ood_reservations/reservation.rb', line 116 def jobs @jobs end |
#ppn ⇒ Fixnum (readonly)
The number of cores on this node
104 105 106 |
# File 'lib/ood_reservations/reservation.rb', line 104 def ppn @ppn end |
#ppn_used ⇒ Fixnum (readonly)
The number of cores used on this node
108 109 110 |
# File 'lib/ood_reservations/reservation.rb', line 108 def ppn_used @ppn_used end |
#props ⇒ Array<Symbol> (readonly)
A list of properties describing this node
112 113 114 |
# File 'lib/ood_reservations/reservation.rb', line 112 def props @props end |
Instance Method Details
#<=>(other) ⇒ Boolean
The comparison operator for sorting values
146 147 148 |
# File 'lib/ood_reservations/reservation.rb', line 146 def <=>(other) to_s <=> other.to_s end |
#eql?(other) ⇒ Boolean
Check whether objects are identical to each other
153 154 155 |
# File 'lib/ood_reservations/reservation.rb', line 153 def eql?(other) self.class == other.class && self == other end |
#hash ⇒ Fixnum
Generate a hash value for this object
159 160 161 |
# File 'lib/ood_reservations/reservation.rb', line 159 def hash [self.class, to_s].hash end |
#is_free? ⇒ Boolean
Is this node free to be used?
133 134 135 |
# File 'lib/ood_reservations/reservation.rb', line 133 def is_free? ppn_used == 0 end |
#to_s ⇒ String
Convert object to string
139 140 141 |
# File 'lib/ood_reservations/reservation.rb', line 139 def to_s id end |