lib/rubyonacid/factories/increment.rb in rubyonacid-0.1.2 vs lib/rubyonacid/factories/increment.rb in rubyonacid-0.2.0

- old
+ new

@@ -1,11 +1,12 @@ require 'rubyonacid/factory' module RubyOnAcid class IncrementFactory < Factory - + + #The amount to increment counters by. attr_accessor :interval def interval=(value) @interval = value @start_value = (@interval < 0.0 ? 1.0 : 0.0) @counters.each_key{|k| @counters[k] = @start_value} @@ -16,10 +17,10 @@ @start_value = 0.0 @counters = {} @interval = interval end - #Increment counter for key and get its sine, then scale it between 0 and 1. + #Increment counter for given key and return it. Constrain between 0 and 1. def get_unit(key) @counters[key] ||= @start_value @counters[key] += @interval @counters[key] = 1.0 if @counters[key] > 1.0 @counters[key] = 0.0 if @counters[key] < 0.0 \ No newline at end of file