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.
18 19 20 |
# File 'lib/nameq/support/pool.rb', line 18 def initialize(list) @list = list end |
Instance Attribute Details
#list ⇒ Object (readonly, protected)
Returns the value of attribute list.
16 17 18 |
# File 'lib/nameq/support/pool.rb', line 16 def list @list end |
Instance Method Details
#entry_factory ⇒ Object (protected)
22 23 24 |
# File 'lib/nameq/support/pool.rb', line 22 def entry_factory Support::StringEntry end |
#take(name) ⇒ String
Take a name from the available pool of names, suffixed if necessary.
9 10 11 12 |
# File 'lib/nameq/support/pool.rb', line 9 def take(name) return list.add(name) unless list.include?(name) resolve(entry_factory.new(name)).tap { |n| list.add(n) } end |