Class: SlavePools::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/slave_pools/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, connections) ⇒ Pool

Returns a new instance of Pool.



5
6
7
8
9
10
# File 'lib/slave_pools/pool.rb', line 5

def initialize(name, connections)
  @name    = name
  @slaves  = connections
  @size    = connections.size
  self.reset
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



3
4
5
# File 'lib/slave_pools/pool.rb', line 3

def current
  @current
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/slave_pools/pool.rb', line 3

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



3
4
5
# File 'lib/slave_pools/pool.rb', line 3

def size
  @size
end

#slavesObject (readonly)

Returns the value of attribute slaves.



3
4
5
# File 'lib/slave_pools/pool.rb', line 3

def slaves
  @slaves
end

Instance Method Details

#nextObject



17
18
19
# File 'lib/slave_pools/pool.rb', line 17

def next
  @current = @cycle.next
end

#resetObject



12
13
14
15
# File 'lib/slave_pools/pool.rb', line 12

def reset
  @cycle   = slaves.cycle
  self.next
end