Sha256: 7a09347b80dd7a27b40731fcfaa98266ce8ebbc3d8fd3c444d52533cae4ca817
Contents?: true
Size: 413 Bytes
Versions: 3
Compression:
Stored size: 413 Bytes
Contents
module Shuck class RateLimitableFile < File @@rate_limit = nil # Specify a rate limit in bytes per second def self.rate_limit @@rate_limit end def self.rate_limit=(rate_limit) @@rate_limit = rate_limit end def read(args) if @@rate_limit time_to_sleep = args / @@rate_limit sleep(time_to_sleep) end return super(args) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shuck-0.1.0 | lib/shuck/rate_limitable_file.rb |
shuck-0.0.9 | lib/shuck/rate_limitable_file.rb |
shuck-0.0.8 | lib/shuck/rate_limitable_file.rb |