Class: Rets::Metadata::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/rets/metadata/file_cache.rb

Overview

This metadata cache persists the metadata to a file.

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileCache

Returns a new instance of FileCache.



7
8
9
# File 'lib/rets/metadata/file_cache.rb', line 7

def initialize(path)
  @path = path
end

Instance Method Details

#load(&block) ⇒ Object

Load the metadata. Should yield an IO-like object to a block; that block will deserialize the metadata from that object and return the metadata. Returns the metadata, or nil if it could not be loaded.



21
22
23
24
25
# File 'lib/rets/metadata/file_cache.rb', line 21

def load(&block)
  File.open(@path, "rb", &block)
rescue IOError, SystemCallError
  nil
end

#save(&block) ⇒ Object

Save the metadata. Should yield an IO-like object to a block; that block will serialize the metadata to that object.



13
14
15
# File 'lib/rets/metadata/file_cache.rb', line 13

def save(&block)
  File.open(@path, "wb", &block)
end