Class: RJL::Metadata
- Inherits:
-
Object
- Object
- RJL::Metadata
- Defined in:
- lib/rjl/metadata.rb
Overview
Gets metadata for an album from allmusic.com, caching the results. See [rjl-music](github.com/richardjlyon/allmusic) for details. Computes a simplified genre by selecting the highest frequency genre and style in the library and combining them in a string. Creates a cache file ‘lib/cache/cache.db`
Instance Attribute Summary collapse
-
#genre(album) ⇒ String
readonly
Compute a genre for album.
-
#genres(album) ⇒ List of String
readonly
allmusic.com genres for album.
-
#styles(album) ⇒ List of String
readonly
allmusic.com styles for album.
Instance Method Summary collapse
-
#initialize(itunes) ⇒ Metadata
constructor
Create a new RJL::Metadata from the supplied Itunes object.
Constructor Details
#initialize(itunes) ⇒ Metadata
Create a new RJL::Metadata from the supplied Itunes object. This opens or creates a cache for storing metadata from allmusic to speed things up, and closes it on exit.
19 20 21 22 23 24 25 |
# File 'lib/rjl/metadata.rb', line 19 def initialize( itunes ) cache_path = File.join((File.dirname __dir__), 'cache/cache.db') @db = Daybreak::DB.new cache_path, :default => {} @itunes = itunes at_exit { @db.close } end |
Instance Attribute Details
#genre(album) ⇒ String (readonly)
Compute a genre for album. Reduce genres and styles and construct a string from them.
43 44 45 |
# File 'lib/rjl/metadata.rb', line 43 def genre @genre end |
#genres(album) ⇒ List of String (readonly)
allmusic.com genres for album.
29 30 31 |
# File 'lib/rjl/metadata.rb', line 29 def genres @genres end |
#styles(album) ⇒ List of String (readonly)
allmusic.com styles for album.
35 36 37 |
# File 'lib/rjl/metadata.rb', line 35 def styles @styles end |