Class: CounterString

Inherits:
String
  • Object
show all
Defined in:
lib/counter_string.rb

Instance Method Summary collapse

Instance Method Details

#nextObject



3
4
5
6
7
8
9
10
11
# File 'lib/counter_string.rb', line 3

def next
  (self.size - 1).downto(0) do |index|
    this_ord = self[index]
    if new_ord = next_ord(this_ord)
      return CounterString.new("#{self[0...index]}#{new_ord.chr}".ljust(self.size, "a"))
    end
  end
  CounterString.new(self.ljust(self.size + 4, "a"))
end