Class: Jekyll::FileCache
- Inherits:
-
Object
- Object
- Jekyll::FileCache
- Defined in:
- lib/jekyll-bluesky.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ FileCache
constructor
A new instance of FileCache.
- #read(key) ⇒ Object
- #write(key, data) ⇒ Object
Constructor Details
#initialize(path) ⇒ FileCache
Returns a new instance of FileCache.
176 177 178 179 |
# File 'lib/jekyll-bluesky.rb', line 176 def initialize(path) @cache_folder = File. path FileUtils.mkdir_p @cache_folder end |
Instance Method Details
#read(key) ⇒ Object
181 182 183 184 |
# File 'lib/jekyll-bluesky.rb', line 181 def read(key) file_to_read = cache_file(key) File.read(file_to_read) if File.exist?(file_to_read) end |
#write(key, data) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/jekyll-bluesky.rb', line 186 def write(key, data) file_to_write = cache_file(key) File.open(file_to_write, 'w') do |f| f.write(data) end end |