Sha256: ab64e5ec4918b5de38294007bb833b9f05faf3c4a1289132d621ba1d9a15b430

Contents?: true

Size: 781 Bytes

Versions: 3

Compression:

Stored size: 781 Bytes

Contents

require 'drbqs/history'

module DRbQS
  class NodeList
    attr_reader :history

    def initialize
      @id = 0
      @list = {}
      @check = []
      @history = History.new
    end

    def get_new_id(id_str)
      @id += 1
      @list[@id] = id_str
      @history.set(@id, :connect, @list[@id])
      @id
    end

    def each(&block)
      @list.each(&block)
    end

    def set_check_connection
      @check = @list.keys
    end

    def delete(id)
      @list.delete(id)
      @history.set(id, :disconnect)
    end

    def delete_not_alive
      @check.each do |id|
        delete(id)
      end
      deleted = @check
      @check = []
      deleted
    end

    def set_alive(id)
      @check.delete(id)
    end

    def empty?
      @list.size == 0
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
drbqs-0.0.13 lib/drbqs/node_list.rb
drbqs-0.0.12 lib/drbqs/node_list.rb
drbqs-0.0.11 lib/drbqs/node_list.rb