Class: NameQ::Support::Pool
- Inherits:
-
Object
- Object
- NameQ::Support::Pool
- Defined in:
- lib/nameq/support/pool.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
protected
Returns the value of attribute list.
Instance Method Summary collapse
- #entry_factory ⇒ Object protected
-
#initialize(list) ⇒ Pool
constructor
protected
A new instance of Pool.
-
#take(name) ⇒ String
Take a name from the available pool of names, suffixed if necessary.
Constructor Details
#initialize(list) ⇒ Pool (protected)
Returns a new instance of Pool.
19 20 21 |
# File 'lib/nameq/support/pool.rb', line 19 def initialize(list) @list = list end |
Instance Attribute Details
#list ⇒ Object (readonly, protected)
Returns the value of attribute list.
17 18 19 |
# File 'lib/nameq/support/pool.rb', line 17 def list @list end |
Instance Method Details
#entry_factory ⇒ Object (protected)
23 24 25 |
# File 'lib/nameq/support/pool.rb', line 23 def entry_factory Support::StringEntry end |
#take(name) ⇒ String
Take a name from the available pool of names, suffixed if necessary.
10 11 12 13 |
# File 'lib/nameq/support/pool.rb', line 10 def take(name) return list.add(name) unless list.include?(name) resolve(entry_factory.new(name)).tap { |n| list.add(n) } end |