class OodReservations::Reservation
Object that describes a generic scheduler reservation
Attributes
The time when this reservation ends @return [Time] reservation end time
The list of groups who have access to this reservation @return [Array<OodSupport::Group>] list of groups with reservation access
The id of the reservation @return [String] reservation id
The list of nodes reserved under this reservation @return [Array<Node>] reserved nodes
The time when this reservation begins @return [Time] reservation start time
The list of users who have access to this reservation @return [Array<OodSupport::User>] list of users with reservation access
Public Class Methods
@param id [#to_s] reservation id @param start_time
[#to_i] reservation start time @param end_time
[#to_i] reservation end time @param users [Array<#to_s>] list of users w/ reservation access @param groups [Array<#to_s>] list of groups w/ reservation access @param nodes [Array<#to_h>] reserved nodes
# File lib/ood_reservations/reservation.rb, line 38 def initialize(id:, start_time:, end_time:, users:, groups:, nodes:) @id = id.to_s @start_time = Time.at(start_time.to_i) @end_time = Time.at(end_time.to_i) @nodes = nodes.map {|n| Node.new(n.to_h)} # Be careful, groups or users can be specified here but not exist anymore @users = users.map {|u| OodSupport::User.new(u.to_s) rescue nil}.reject(&:nil?) @groups = groups.map {|g| OodSupport::Group.new(g.to_s) rescue nil}.reject(&:nil?) end
Public Instance Methods
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 76 def <=>(other) to_s <=> other.to_s end
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 83 def eql?(other) self.class == other.class && self == other end
The list of nodes that are completely free to use @return [Array<Node>] free nodes
# File lib/ood_reservations/reservation.rb, line 63 def free_nodes nodes.select(&:is_free?) end
Whether this reservation has ended yet? @return [Boolean] whether reservation has ended
# File lib/ood_reservations/reservation.rb, line 57 def has_ended? Time.now >= end_time end
Whether this reservation has started yet? @return [Boolean] whether reservation has started
# File lib/ood_reservations/reservation.rb, line 51 def has_started? Time.now >= start_time end
Generate a hash value for this object @return [Fixnum] hash value of object
# File lib/ood_reservations/reservation.rb, line 89 def hash [self.class, to_s].hash end
Convert object to string @return [String] the string describing this object
# File lib/ood_reservations/reservation.rb, line 69 def to_s id end