Class: MusicBox::Catalog::AlbumTrack
- Inherits:
-
Object
- Object
- MusicBox::Catalog::AlbumTrack
- Defined in:
- lib/musicbox/catalog/album_track.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
Returns the value of attribute album.
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#disc ⇒ Object
Returns the value of attribute disc.
-
#file ⇒ Object
Returns the value of attribute file.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#track ⇒ Object
Returns the value of attribute track.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ AlbumTrack
constructor
A new instance of AlbumTrack.
- #load_tags ⇒ Object
- #path ⇒ Object
- #save_tags ⇒ Object
- #to_h ⇒ Object
- #update_tags ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ AlbumTrack
Returns a new instance of AlbumTrack.
15 16 17 |
# File 'lib/musicbox/catalog/album_track.rb', line 15 def initialize(params={}) params.each { |k, v| send("#{k}=", v) } end |
Instance Attribute Details
#album ⇒ Object
Returns the value of attribute album.
11 12 13 |
# File 'lib/musicbox/catalog/album_track.rb', line 11 def album @album end |
#artist ⇒ Object
Returns the value of attribute artist.
8 9 10 |
# File 'lib/musicbox/catalog/album_track.rb', line 8 def artist @artist end |
#disc ⇒ Object
Returns the value of attribute disc.
10 11 12 |
# File 'lib/musicbox/catalog/album_track.rb', line 10 def disc @disc end |
#file ⇒ Object
Returns the value of attribute file.
12 13 14 |
# File 'lib/musicbox/catalog/album_track.rb', line 12 def file @file end |
#tags ⇒ Object
Returns the value of attribute tags.
13 14 15 |
# File 'lib/musicbox/catalog/album_track.rb', line 13 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/musicbox/catalog/album_track.rb', line 7 def title @title end |
#track ⇒ Object
Returns the value of attribute track.
9 10 11 |
# File 'lib/musicbox/catalog/album_track.rb', line 9 def track @track end |
Instance Method Details
#load_tags ⇒ Object
27 28 29 |
# File 'lib/musicbox/catalog/album_track.rb', line 27 def @tags ||= Tags.load(path) end |
#path ⇒ Object
23 24 25 |
# File 'lib/musicbox/catalog/album_track.rb', line 23 def path @album.dir / @file end |
#save_tags ⇒ Object
31 32 33 |
# File 'lib/musicbox/catalog/album_track.rb', line 31 def @tags.save(path) end |
#to_h ⇒ Object
52 53 54 55 56 57 58 59 60 |
# 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 ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/musicbox/catalog/album_track.rb', line 35 def @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 |