Class: CacheManager
- Inherits:
-
Object
- Object
- CacheManager
- Defined in:
- lib/file.rb
Overview
f = Files.new(Hash.new) f.add(“lib/beaver.rb”) pack = msg = MessagePack.pack(f) p pack p MessagePack::unpack(pack)
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
Instance Method Summary collapse
-
#initialize ⇒ CacheManager
constructor
A new instance of CacheManager.
- #save ⇒ Object
Constructor Details
#initialize ⇒ CacheManager
Returns a new instance of CacheManager.
70 71 72 73 74 75 76 77 |
# File 'lib/file.rb', line 70 def initialize begin @files = MessagePack::unpack(File.read $beaver.file_cache_file) rescue EOFError @files = Files.new(Hash.new) @files.add("__BEAVER__CONFIG__", $PROGRAM_NAME) end end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
68 69 70 |
# File 'lib/file.rb', line 68 def files @files end |
Instance Method Details
#save ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/file.rb', line 79 def save packed = MessagePack.pack(@files) unless Dir.exist? $beaver.cache_loc Dir.mkdir $beaver.cache_loc end File.binwrite($beaver.file_cache_file, packed) end |