class OodCluster::Cluster

An object that describes a given cluster of nodes used by an HPC center

Public Class Methods

new(servers: {}, hpc_cluster: true, **_) click to toggle source

@param servers [Hash{#to_sym=>Server}] hash of servers @param hpc_cluster [Boolean] whether this is an hpc cluster

# File lib/ood_cluster/cluster.rb, line 11
def initialize(servers: {}, hpc_cluster: true, **_)
  @servers = servers.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
  @hpc_cluster = hpc_cluster
end

Public Instance Methods

==(other) click to toggle source

The comparison operator @param other [#to_h] object to compare against @return [Boolean] whether objects are equivalent

# File lib/ood_cluster/cluster.rb, line 55
def ==(other)
  to_h == other.to_h
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_cluster/cluster.rb, line 62
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_cluster/cluster.rb, line 68
def hash
  [self.class, to_h].hash
end
hpc_cluster?() click to toggle source

Whether this is an hpc-style cluster (i.e., meant for heavy computation) @return [Boolean] whether this an hpc-style cluster

# File lib/ood_cluster/cluster.rb, line 27
def hpc_cluster?
  @hpc_cluster
end
method_missing(method_name, *arguments, &block) click to toggle source

Grab object from {@servers} hash or check if it exists @param method_name the method name called @param arguments the arguments to the call @param block an optional block for the call

Calls superclass method
# File lib/ood_cluster/cluster.rb, line 35
def method_missing(method_name, *arguments, &block)
  if /^(.+)_server$/ =~ method_name.to_s
    @servers.fetch($1.to_sym, nil)
  elsif /^(.+)_server\?$/ =~ method_name.to_s
    @servers.has_key?($1.to_sym)
  else
    super
  end
end
respond_to_missing?(method_name, include_private = false) click to toggle source

Check if method ends with custom *_server or *_server? @param method_name the method name to check @return [Boolean]

Calls superclass method
# File lib/ood_cluster/cluster.rb, line 48
def respond_to_missing?(method_name, include_private = false)
  method_name.to_s.end_with?('_server', '_server?') || super
end
to_h() click to toggle source

Convert object to hash @return [Hash] the hash describing this object

# File lib/ood_cluster/cluster.rb, line 18
def to_h
  {
    servers: @servers,
    hpc_cluster: @hpc_cluster
  }
end