Class: DRbQS::NodeList

Inherits:
Object
  • Object
show all
Defined in:
lib/drbqs/node_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNodeList

Returns a new instance of NodeList.



7
8
9
10
11
12
# File 'lib/drbqs/node_list.rb', line 7

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

Instance Attribute Details

#historyObject (readonly)

Returns the value of attribute history.



5
6
7
# File 'lib/drbqs/node_list.rb', line 5

def history
  @history
end

Instance Method Details

#delete(id) ⇒ Object



29
30
31
32
# File 'lib/drbqs/node_list.rb', line 29

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

#delete_not_aliveObject



34
35
36
37
38
39
40
41
# File 'lib/drbqs/node_list.rb', line 34

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

#each(&block) ⇒ Object



21
22
23
# File 'lib/drbqs/node_list.rb', line 21

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

#empty?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/drbqs/node_list.rb', line 47

def empty?
  @list.size == 0
end

#get_new_id(id_str) ⇒ Object



14
15
16
17
18
19
# File 'lib/drbqs/node_list.rb', line 14

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

#set_alive(id) ⇒ Object



43
44
45
# File 'lib/drbqs/node_list.rb', line 43

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

#set_check_connectionObject



25
26
27
# File 'lib/drbqs/node_list.rb', line 25

def set_check_connection
  @check = @list.keys
end