Class: Rutaci::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/rutaci/source.rb

Overview

This class collects the taginfo from various sources. Planed are

  • Taglib: use taglib to get the info trom a file

  • Filename: use the file’s name and path to extract the info

  • Musicbrainz: use an acoustic fingerprint to lookup the info at musicbrainz.org

  • Commandline: get the info from commandline parameters (dummy, all the work is already done by the OptionParser)

Direct Known Subclasses

CommandlineSource, FilenameSource, TaglibSource

Class Method Summary collapse

Class Method Details

.factory(filename, options = {}) ⇒ Object

this class function returns an source object, which type is determined by the options



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rutaci/source.rb', line 27

def self.factory(filename, options = {})
  # if the info is given in the command line, options.fields is a Hash (else: nil or Array)
  return CommandlineSource.new(options) if options.fields.class == Hash

  if options.musicbrainz
    require 'rutaci/musicbrainz_source'
    return MusicbrainzSource.new(filename, options)
  end

  if options.format and options.command == :set
    require 'rutaci/filename_source'
    return FilenameSource.new(filename, options)
  end

  # the default source is taglib
  require 'rutaci/taglib_source'
  return TaglibSource.new(filename, options)
end