diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-17 03:39:50 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-17 03:39:50 -0700 |
commit | 0f708ecde00919a9bdf693443aa929cdeaceebea (patch) | |
tree | 280248dfa44b021d267f1366d6f26f2d38c7cce7 /omptagger | |
parent | e28c1f9fc519b2f610a8cd26409368640bd95c85 (diff) | |
download | omptagger-0f708ecde00919a9bdf693443aa929cdeaceebea.tar.gz omptagger-0f708ecde00919a9bdf693443aa929cdeaceebea.tar.xz |
More abstraction!
Diffstat (limited to 'omptagger')
-rwxr-xr-x | omptagger | 40 |
1 files changed, 21 insertions, 19 deletions
@@ -301,9 +301,17 @@ class Metadata Output.info(@filename) end + + def save + save_fields if @write + + File.rename(@origname, @filename) unless @filename == @origname + end end class VorbisComment < Metadata + private + def keys Hash['a' => 'ARTIST', 'b' => 'ALBUM', @@ -312,30 +320,24 @@ class VorbisComment < Metadata 't' => 'TITLE'] end - def save - if @write - read.each_key do |field| - metadata.removeField(TagLib::String.new(field)) - end - - @metadata.each do |field, value| - field = TagLib::String.new(field) - - value.each do |value| - metadata.addField(field, TagLib::String.new(value), false) - end - end + def read + metadata.fieldListMap.hash + end - @file.save + def save_fields + read.each_key do |field| + metadata.removeField(TagLib::String.new(field)) end - File.rename(@origname, @filename) unless @filename == @origname - end + @metadata.each do |field, value| + field = TagLib::String.new(field) - private + value.each do |value| + metadata.addField(field, TagLib::String.new(value), false) + end + end - def read - metadata.fieldListMap.hash + @file.save end def valid_field?(field) |