class NameQ::Support::Pool
Attributes
list[R]
Public Class Methods
new(list)
click to toggle source
# File lib/nameq/support/pool.rb, line 19 def initialize(list) @list = list end
Public Instance Methods
take(name)
click to toggle source
Take a name from the available pool of names, suffixed if necessary. @param name [String] the name to find a variant of within the pool @return [String] the resolved name from the pool
# 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
Protected Instance Methods
entry_factory()
click to toggle source
# File lib/nameq/support/pool.rb, line 23 def entry_factory Support::StringEntry end
Private Instance Methods
resolve(entry)
click to toggle source
# File lib/nameq/support/pool.rb, line 29 def resolve(entry) suffixes.each do |suffix| resolution = entry.resolve(suffix) return resolution unless list.include?(resolution) end end
suffixes()
click to toggle source
# File lib/nameq/support/pool.rb, line 36 def suffixes (1..Float::INFINITY).lazy.map { |i| Suffix.new(i) } end