Class: Feed2Gram::LoadsCache

Inherits:
Object
  • Object
show all
Defined in:
lib/feed2gram/loads_cache.rb

Instance Method Summary collapse

Instance Method Details

#load(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/feed2gram/loads_cache.rb', line 9

def load(options)
  if File.exist?(options.cache_path)
    puts "Loading cache from: #{options.cache_path}" if options.verbose
    yaml = YAML.load_file(options.cache_path, permitted_classes: [Time])
    Cache.new(**yaml)
  else
    puts "No cache found (looked at '#{options.cache_path}'), initializing a new one" if options.verbose
    Cache.new(posted: [], failed: [], skipped: [])
  end
end