Sha256: 74911857c028d85d95781c94378bf6722bac8480085f8e385730d3669128d516
Contents?: true
Size: 416 Bytes
Versions: 4
Compression:
Stored size: 416 Bytes
Contents
require 'rubyonacid/factory' module RubyOnAcid class SineFactory < Factory attr_accessor :interval def initialize(interval = 0.1) super @counters = {} @interval = interval end #Increment counter for key and get its sine, then scale it between 0 and 1. def get_unit(key) @counters[key] ||= 0 @counters[key] += @interval (Math.sin(@counters[key]) + 1) / 2 end end end
Version data entries
4 entries across 4 versions & 1 rubygems