class MusicBox::Catalog::AlbumTrack

Attributes

album[RW]
artist[RW]
disc[RW]
file[RW]
tags[RW]
title[RW]
track[RW]

Public Class Methods

new(params={}) click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 15
def initialize(params={})
  params.each { |k, v| send("#{k}=", v) }
end

Public Instance Methods

file=(file) click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 19
def file=(file)
  @file = Path.new(file)
end
load_tags() click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 27
def load_tags
  @tags ||= Tags.load(path)
end
path() click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 23
def path
  @album.dir / @file
end
save_tags() click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 31
def save_tags
  @tags.save(path)
end
to_h() click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 52
def to_h
  {
    title: @title,
    artist: @artist,
    track: @track,
    disc: @disc,
    file: @file.to_s,
  }.compact
end
update_tags() click to toggle source
# File lib/musicbox/catalog/album_track.rb, line 35
def update_tags
  load_tags
  @tags.update(
    {
      title: @title,
      album: @album.title,
      track: @track,
      disc: @disc,
      discs: @album.discs,
      artist: @artist || @album.artist,
      album_artist: @album.artist,
      grouping: @album.title,
      year: @album.year,
    }.reject { |k, v| v.to_s.empty? }
  )
end