Class: FakeS3::RateLimitableFile

Inherits:
File
  • Object
show all
Defined in:
lib/fakes3/rate_limitable_file.rb

Constant Summary collapse

@@rate_limit =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rate_limitObject

Specify a rate limit in bytes per second



5
6
7
# File 'lib/fakes3/rate_limitable_file.rb', line 5

def self.rate_limit
  @@rate_limit
end

.rate_limit=(rate_limit) ⇒ Object



9
10
11
# File 'lib/fakes3/rate_limitable_file.rb', line 9

def self.rate_limit=(rate_limit)
  @@rate_limit = rate_limit
end

Instance Method Details

#read(args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/fakes3/rate_limitable_file.rb', line 13

def read(args)
  if @@rate_limit
    time_to_sleep = args / @@rate_limit
    sleep(time_to_sleep)
  end
  return super(args)
end