Class: Resque::Reports::CacheFile
- Inherits:
-
Object
- Object
- Resque::Reports::CacheFile
- Defined in:
- lib/resque/reports/cache_file.rb
Constant Summary collapse
- DEFAULT_EXPIRE_TIME =
86400- DEFAULT_CODING =
'utf-8'
Instance Method Summary collapse
- #exists? ⇒ Boolean (also: #ready?)
- #filename ⇒ Object
-
#initialize(dir, filename, options = {}) ⇒ CacheFile
constructor
TODO: Description!.
- #open ⇒ Object
Constructor Details
#initialize(dir, filename, options = {}) ⇒ CacheFile
TODO: Description!
10 11 12 13 14 15 16 17 |
# File 'lib/resque/reports/cache_file.rb', line 10 def initialize(dir, filename, = {}) @dir = dir @filename = File.join(dir, filename) # options @coding = [:coding] || DEFAULT_CODING @expiration_time = [:expire_in] || DEFAULT_EXPIRE_TIME end |
Instance Method Details
#exists? ⇒ Boolean Also known as: ready?
19 20 21 |
# File 'lib/resque/reports/cache_file.rb', line 19 def exists? File.exists?(@filename) end |
#filename ⇒ Object
24 25 26 27 |
# File 'lib/resque/reports/cache_file.rb', line 24 def filename raise "File doesn't exists, check for its existance before" unless exists? @filename end |
#open ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/resque/reports/cache_file.rb', line 29 def open prepare_cache_dir remove_unfinished_on_error do File.open(@filename, @coding) do |file| yield file end end end |