summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-17 03:39:50 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-17 03:39:50 -0700
commit0f708ecde00919a9bdf693443aa929cdeaceebea (patch)
tree280248dfa44b021d267f1366d6f26f2d38c7cce7
parente28c1f9fc519b2f610a8cd26409368640bd95c85 (diff)
downloadomptagger-0f708ecde00919a9bdf693443aa929cdeaceebea.tar.gz
omptagger-0f708ecde00919a9bdf693443aa929cdeaceebea.tar.xz
More abstraction!
-rwxr-xr-xomptagger40
1 files changed, 21 insertions, 19 deletions
diff --git a/omptagger b/omptagger
index 07fb2ed..472562e 100755
--- a/omptagger
+++ b/omptagger
@@ -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)