Class: Nem::NodePool

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/nem/node_pool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ NodePool

Returns a new instance of NodePool.



13
14
15
16
# File 'lib/nem/node_pool.rb', line 13

def initialize(nodes)
  @nodes = nodes
  @failed = []
end

Instance Attribute Details

#failedObject (readonly)

Returns the value of attribute failed.



7
8
9
# File 'lib/nem/node_pool.rb', line 7

def failed
  @failed
end

#nodesObject (readonly)

Returns the value of attribute nodes.



7
8
9
# File 'lib/nem/node_pool.rb', line 7

def nodes
  @nodes
end

Class Method Details

.from_hash(definitions) ⇒ Object



9
10
11
# File 'lib/nem/node_pool.rb', line 9

def self.from_hash(definitions)
  new(definitions.map { |d| Nem::Node.new(d) })
end

Instance Method Details

#<<(definitioin) ⇒ Object



27
28
29
# File 'lib/nem/node_pool.rb', line 27

def <<(definitioin)
  @nodes << Nem::Node.new(definitioin)
end

#currentObject



18
19
20
# File 'lib/nem/node_pool.rb', line 18

def current
  @nodes.first
end

#next!Object



22
23
24
25
# File 'lib/nem/node_pool.rb', line 22

def next!
  @failed << @nodes.shift
  raise 'Exhausted node pool' if length.zero?
end