Class: IRC::Util::NickGenerator
- Inherits:
-
Object
- Object
- IRC::Util::NickGenerator
- Defined in:
- lib/irc/util/nick_generator.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(nick, nick_length = nil, max_nicks = 10) ⇒ NickGenerator
constructor
A new instance of NickGenerator.
- #pop ⇒ Object
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
#names ⇒ Object (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
#each ⇒ Object
46 47 48 |
# File 'lib/irc/util/nick_generator.rb', line 46 def each @names.each { |name| yield name } end |
#pop ⇒ Object
50 51 52 |
# File 'lib/irc/util/nick_generator.rb', line 50 def pop @names.pop end |