Class: OodCluster::Server

Inherits:
Object
  • Object
show all
Includes:
JsonSerializer
Defined in:
lib/ood_cluster/server.rb

Overview

An object that describes a server hosted by a given cluster

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonSerializer

included, #to_json

Constructor Details

#initialize(host:, **_) ⇒ Server

Returns a new instance of Server.

Parameters:

  • host (#to_s)

    host of server



15
16
17
# File 'lib/ood_cluster/server.rb', line 15

def initialize(host:, **_)
  @host = host.to_s
end

Instance Attribute Details

#hostString (readonly)

The host information for this server object

Examples:

Host information for login node

"my_server.host" #=> "oakley.osc.edu"

Returns:

  • (String)

    the host for this server



12
13
14
# File 'lib/ood_cluster/server.rb', line 12

def host
  @host
end

Instance Method Details

#==(other) ⇒ Boolean

The comparison operator

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are equivalent



28
29
30
# File 'lib/ood_cluster/server.rb', line 28

def ==(other)
  to_h == other.to_h
end

#eql?(other) ⇒ Boolean

Check whether objects are identical to each other

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are identical



35
36
37
# File 'lib/ood_cluster/server.rb', line 35

def eql?(other)
  self.class == other.class && self == other
end

#hashFixnum

Generate a hash value for this object

Returns:

  • (Fixnum)

    hash value of object



41
42
43
# File 'lib/ood_cluster/server.rb', line 41

def hash
  [self.class, to_h].hash
end

#to_hHash

Convert object to hash

Returns:

  • (Hash)

    the hash describing this object



21
22
23
# File 'lib/ood_cluster/server.rb', line 21

def to_h
  {host: @host.to_s}
end