# frozen_string_literal: true
require 'securerandom'
# A collective for a tally
class Cluster
attr_reader :count, :name, :status, :uuid, :created_on
@@clusters = {}
def initialize(name)
@uuid = SecureRandom.uuid
@name = name
@count = 0
@status = :open
@mutex = Mutex.new
@created_on = Time.new
@@clusters[@uuid] = self
end
def increment(var = 1)
@mutex.synchronize do
@count += var
def decrement(var = 1)
@count -= var
class << self
def get(uuid)
@@clusters[uuid]
def list
@@clusters