Class: IMP3::Cache
Constant Summary collapse
Instance Method Summary collapse
- #artist_genres ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/imp3/cache.rb', line 8 def initialize @data = {} if File.exist?(CACHE_FILE) begin @data = YAML.load_file(CACHE_FILE) rescue raise "Unable to read cache file #{CACHE_FILE}" end end end |
Instance Method Details
#artist_genres ⇒ Object
20 21 22 23 |
# File 'lib/imp3/cache.rb', line 20 def artist_genres @data[:artist_genres] ||= {} @data[:artist_genres] end |
#save ⇒ Object
25 26 27 |
# File 'lib/imp3/cache.rb', line 25 def save File.new(CACHE_FILE, "w+").write(@data.to_yaml) end |