Class: RJL::Metadata

Inherits:
Object
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • itunes (Itunes)

    the itunes client to generate metadata for



19
20
21
22
23
# File 'lib/rjl/metadata.rb', line 19

def initialize( itunes )
  @db = Daybreak::DB.new 'cache.db', :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.

Parameters:

Returns:

  • (String)

    computed genre for album



41
42
43
# File 'lib/rjl/metadata.rb', line 41

def genre
  @genre
end

#genres(album) ⇒ List of String (readonly)

allmusic.com genres for album.

Returns:

  • (List of String)

    allmusic.com genres for album



27
28
29
# File 'lib/rjl/metadata.rb', line 27

def genres
  @genres
end

#styles(album) ⇒ List of String (readonly)

allmusic.com styles for album.

Returns:

  • (List of String)

    allmusic.com styles for album



33
34
35
# File 'lib/rjl/metadata.rb', line 33

def styles
  @styles
end