Class: Mp3::Disc
- Inherits:
-
Object
- Object
- Mp3::Disc
- Includes:
- Utils::Formatter, Utils::Parser
- Defined in:
- lib/mp3/disc.rb
Constant Summary
Constants included from Utils::Formatter
Utils::Formatter::FORMAT_FOR_OTHERS, Utils::Formatter::FORMAT_FOR_X, Utils::Formatter::FORMAT_FOR_XX, Utils::Formatter::FORMAT_FOR_XXX
Instance Attribute Summary collapse
-
#album_artist ⇒ Object
Returns the value of attribute album_artist.
-
#album_title ⇒ Object
Returns the value of attribute album_title.
-
#album_year ⇒ Object
Returns the value of attribute album_year.
-
#disc_number ⇒ Object
Returns the value of attribute disc_number.
-
#disc_title ⇒ Object
Returns the value of attribute disc_title.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
- #add(item) ⇒ Object
-
#initialize(*args) ⇒ Disc
constructor
A new instance of Disc.
- #rename(number_of_discs) ⇒ Object
- #update_id3_tags ⇒ Object
- #write ⇒ Object
Methods included from Utils::Parser
#parse_args, #parse_array, #parse_hash
Methods included from Utils::Formatter
Constructor Details
#initialize(*args) ⇒ Disc
Returns a new instance of Disc.
23 24 25 26 27 28 29 30 |
# File 'lib/mp3/disc.rb', line 23 def initialize(*args) @disc_title = '' @tracks = [] @separator = '.' @prefix = 'D' @suffix = '' parse_args(nil, args) end |
Instance Attribute Details
#album_artist ⇒ Object
Returns the value of attribute album_artist.
15 16 17 |
# File 'lib/mp3/disc.rb', line 15 def album_artist @album_artist end |
#album_title ⇒ Object
Returns the value of attribute album_title.
16 17 18 |
# File 'lib/mp3/disc.rb', line 16 def album_title @album_title end |
#album_year ⇒ Object
Returns the value of attribute album_year.
17 18 19 |
# File 'lib/mp3/disc.rb', line 17 def album_year @album_year end |
#disc_number ⇒ Object
Returns the value of attribute disc_number.
13 14 15 |
# File 'lib/mp3/disc.rb', line 13 def disc_number @disc_number end |
#disc_title ⇒ Object
Returns the value of attribute disc_title.
14 15 16 |
# File 'lib/mp3/disc.rb', line 14 def disc_title @disc_title end |
#prefix ⇒ Object
Returns the value of attribute prefix.
20 21 22 |
# File 'lib/mp3/disc.rb', line 20 def prefix @prefix end |
#separator ⇒ Object
Returns the value of attribute separator.
19 20 21 |
# File 'lib/mp3/disc.rb', line 19 def separator @separator end |
#suffix ⇒ Object
Returns the value of attribute suffix.
21 22 23 |
# File 'lib/mp3/disc.rb', line 21 def suffix @suffix end |
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
18 19 20 |
# File 'lib/mp3/disc.rb', line 18 def tracks @tracks end |
Instance Method Details
#add(item) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/mp3/disc.rb', line 32 def add(item) if item.class.name == Track.name @tracks << item end self end |
#rename(number_of_discs) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mp3/disc.rb', line 39 def rename(number_of_discs) @disc_title = format(@prefix, @separator, @suffix, @disc_number, number_of_discs) tracks.each do |track| track.album_artist = @album_artist track.album_title = @album_title track.album_year = @album_year track.rename(@disc_title, tracks.size) end end |
#update_id3_tags ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mp3/disc.rb', line 52 def disc_subdir = "#{@album_title} [#{@disc_title}]" here = Dir.pwd Dir.chdir disc_subdir @tracks.each do |track| track. end Dir.chdir here end |
#write ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mp3/disc.rb', line 65 def write disc_subdir = "#{@album_title} [#{@disc_title}]" if $DEBUG print "\n\talbum title = #{@album_title}" print "\n\tdisc title = #{@disc_title}" print "\n\tdisc subdir = #{disc_subdir}" end File.makedirs(disc_subdir) here = Dir.pwd Dir.chdir disc_subdir @tracks.each do |track| track.write end Dir.chdir here end |