Module: PictureTag::Cache::Base
Overview
Basic image information cache functionality
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #initialize(base_name) ⇒ Object
-
#write ⇒ Object
Call after updating data.
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/jekyll_picture_tag/cache/base.rb', line 11 def [](key) data[key] end |
#[]=(key, value) ⇒ Object
15 16 17 18 19 |
# File 'lib/jekyll_picture_tag/cache/base.rb', line 15 def []=(key, value) raise ArgumentError unless template.keys.include? key data[key] = value end |
#initialize(base_name) ⇒ Object
7 8 9 |
# File 'lib/jekyll_picture_tag/cache/base.rb', line 7 def initialize(base_name) @base_name = base_name end |
#write ⇒ Object
Call after updating data.
22 23 24 25 26 27 28 |
# File 'lib/jekyll_picture_tag/cache/base.rb', line 22 def write FileUtils.mkdir_p(File.join(base_directory, sub_directory)) File.open(filename, 'w+') do |f| f.write JSON.generate(data) end end |