Class: JekyllEmbedlyPlugin::FileCache
- Inherits:
-
Object
- Object
- JekyllEmbedlyPlugin::FileCache
- Defined in:
- lib/jekyll-embedly-plugin.rb
Instance Method Summary collapse
-
#initialize ⇒ FileCache
constructor
A new instance of FileCache.
- #read(key) ⇒ Object
- #write(key, response) ⇒ Object
Constructor Details
#initialize ⇒ FileCache
Returns a new instance of FileCache.
10 11 12 13 |
# File 'lib/jekyll-embedly-plugin.rb', line 10 def initialize @cache_folder = File.(".embedly-cache") FileUtils.mkdir_p @cache_folder end |
Instance Method Details
#read(key) ⇒ Object
15 16 17 18 |
# File 'lib/jekyll-embedly-plugin.rb', line 15 def read(key) file_to_read = cache_file(cache_filename(key)) File.read(file_to_read) if File.exist?(file_to_read) end |
#write(key, response) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/jekyll-embedly-plugin.rb', line 20 def write(key, response) file_to_write = cache_file(cache_filename(key)) File.open(file_to_write, 'w') do |f| f.write(response) end end |