Sha256: 09ca46df324d9fb618134285ff129d9b3dfe3e2786ff5b47c04b9b7a6a04ce5d

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

module OodCore
  module Job
    # An object that describes the resources used on a specific node
    class NodeInfo
      # The name of the host machine
      # @return [String] node name
      attr_reader :name

      # The number of procs reserved on the given machine
      # @return [Fixnum, nil] number of procs
      attr_reader :procs

      # @param name [#to_s] node name
      # @param procs [#to_i, nil] number of procs
      def initialize(name:, procs: nil, **_)
        @name  = name.to_s
        @procs = procs && procs.to_i
      end

      # Convert object to hash
      # @return [Hash] object as hash
      def to_h
        { name: name, procs: procs }
      end

      # The comparison operator
      # @param other [#to_h] object to compare against
      # @return [Boolean] whether objects are equivalent
      def ==(other)
        to_h == other.to_h
      end

      # Whether objects are identical to each other
      # @param other [#to_h] object to compare against
      # @return [Boolean] whether objects are identical
      def eql?(other)
        self.class == other.class && self == other
      end

      # Generate a hash value for this object
      # @return [Fixnum] hash value of object
      def hash
        [self.class, to_h].hash
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ood_core-0.2.1 lib/ood_core/job/node_info.rb
ood_core-0.2.0 lib/ood_core/job/node_info.rb
ood_core-0.1.1 lib/ood_core/job/node_info.rb
ood_core-0.1.0 lib/ood_core/job/node_info.rb
ood_core-0.0.5 lib/ood_core/job/node_info.rb
ood_core-0.0.4 lib/ood_core/job/node_info.rb
ood_core-0.0.3 lib/ood_core/job/node_info.rb
ood_core-0.0.2 lib/ood_core/job/node_info.rb
ood_core-0.0.1 lib/ood_core/job/node_info.rb