Sha256: 853700ad8852a42fbd6a86c74a462eb6bfd3ed5b588f22c3c39084325860a40b
Contents?: true
Size: 657 Bytes
Versions: 1
Compression:
Stored size: 657 Bytes
Contents
require 'rubyonacid/factory' module RubyOnAcid #Produces a "wave" pattern. class SineFactory < Factory #Counters used to calculate sine values will be incremented by this amount with each query. attr_accessor :interval #Takes a hash with all keys supported by Factory, plus these keys and defaults: # :interval => 0.1 def initialize(options = {}) super @counters = {} @interval = options[:interval] || 0.1 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyonacid-0.4.0 | lib/rubyonacid/factories/sine.rb |