Class: IRC::Util::NickGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/irc/util/nick_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nick, nick_length = nil, max_nicks = 10) ⇒ NickGenerator

Returns a new instance of NickGenerator.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/irc/util/nick_generator.rb', line 34

def initialize(nick, nick_length = nil, max_nicks = 10)
  
  nick_length = !nick_length.nil? ? nick_length : nick.size + max_nicks.to_s.length 
  
  @names = Array.new
  
  1.upto(max_nicks) do |number|
    @names << nick[0, nick_length - number.to_s.size] + number.to_s
  end
  
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



32
33
34
# File 'lib/irc/util/nick_generator.rb', line 32

def names
  @names
end

Instance Method Details

#eachObject



46
47
48
# File 'lib/irc/util/nick_generator.rb', line 46

def each
  @names.each { |name| yield name }
end

#popObject



50
51
52
# File 'lib/irc/util/nick_generator.rb', line 50

def pop
  @names.pop
end