Sha256: 6567894185df92136794238e6f1dd23f2283d863a68ea90d26911dbd32df14d3

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

module Tagomatic

  class TagCleaner

    def process(tags_hash)
      artist = tags_hash['a']
      artist = Regexp.compile("[ -]*#{Regexp.escape(artist)}[ -]*", Regexp::IGNORECASE) if artist

      album = tags_hash['b']
      album = album.sub(artist, '') if artist and album
      tags_hash['b'] = album unless album.nil? or album.empty?

      album = Regexp.compile("[ -]*#{Regexp.escape(album)}[ -]*", Regexp::IGNORECASE) if album

      title = tags_hash['t']
      title = title.sub(artist, '') if artist and title
      title = title.sub(album, '') if album and title
      tags_hash['t'] = title unless title.nil? or title.empty?

      tags_hash
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tagomatic-0.1.9 lib/tagomatic/tag_cleaner.rb
tagomatic-0.1.8 lib/tagomatic/tag_cleaner.rb