class GenSid::CounterAlpha
Public Class Methods
new(initial_value = 'A')
click to toggle source
Calls superclass method
GenSid::Counter::new
# File lib/gen_sid/counter_alpha.rb, line 5 def initialize(initial_value = 'A') super(initial_value) end
Public Instance Methods
increment()
click to toggle source
# File lib/gen_sid/counter_alpha.rb, line 24 def increment @previous_value = @current_value if @current_value.nil? @current_value = @initial_value else if @current_value == 'Z' @current_value = 'A' else @current_value = (@current_value[0].ord + 1).chr end end end
next_value()
click to toggle source
# File lib/gen_sid/counter_alpha.rb, line 13 def next_value increment if @skip_first_value increment @skip_first_value = false end next_val = @current_value status = @previous_value == 'Z' ? :rollover : :normal [next_val,status] end
value()
click to toggle source
# File lib/gen_sid/counter_alpha.rb, line 9 def value @current_value.nil? ? @initial_value : @current_value end