class GenSid::CounterNum

Public Class Methods

new(initial_value = 0) click to toggle source
Calls superclass method GenSid::Counter::new
# File lib/gen_sid/counter_num.rb, line 5
def initialize(initial_value = 0)
  super(initial_value)
end

Public Instance Methods

increment() click to toggle source
# File lib/gen_sid/counter_num.rb, line 24
def increment
  @previous_value = @current_value
  if @current_value.nil?
    @current_value = @initial_value
  else
    if @current_value == 9
      @current_value = 0
    else
      @current_value += 1
    end
  end
end
next_value() click to toggle source
# File lib/gen_sid/counter_num.rb, line 13
def next_value
  increment
  if @skip_first_value
    increment
    @skip_first_value = false
  end
  next_val = @current_value
  status = @previous_value == 9 ? :rollover : :normal
  [next_val,status]
end
value() click to toggle source
# File lib/gen_sid/counter_num.rb, line 9
def value
  @current_value.nil? ? @initial_value : @current_value
end