Class: Feedzirra::Backend::Filesystem

Inherits:
Object
  • Object
show all
Defined in:
lib/feedzirra/backend/filesystem.rb

Constant Summary collapse

DEFAULTS =
{
  :path => File.expand_path(File.join(%w[ ~ / .feedzirra ]))
}

Instance Method Summary collapse

Constructor Details

#initialize(options = { }) ⇒ Filesystem

Returns a new instance of Filesystem.



12
13
14
# File 'lib/feedzirra/backend/filesystem.rb', line 12

def initialize(options = { })
  @options = DEFAULTS.merge(options)
end

Instance Method Details

#get(url) ⇒ Object



16
17
18
19
# File 'lib/feedzirra/backend/filesystem.rb', line 16

def get(url)
  f = filename_for(url)
  Marshal.load(File.read(f)) if File.exist?(f)
end

#set(url, result) ⇒ Object



21
22
23
# File 'lib/feedzirra/backend/filesystem.rb', line 21

def set(url, result)
  File.open(filename_for(url), 'w') {|f| f.write(Marshal.dump(result)) }
end