summaryrefslogtreecommitdiff
path: root/omptagger
diff options
context:
space:
mode:
Diffstat (limited to 'omptagger')
-rwxr-xr-xomptagger16
1 files changed, 10 insertions, 6 deletions
diff --git a/omptagger b/omptagger
index 4397591..205717b 100755
--- a/omptagger
+++ b/omptagger
@@ -12,12 +12,16 @@ require 'getoptlong'
require 'rubygems'
require 'TagLib'
-class Metadata
- def output(tag, val)
- spacing = 2 + @tags.keys.inject(0) do |length, object|
- object.length > length ? object.length : length
- end - tag.length
+class Hash
+ def longest_key_length
+ self.keys.inject(0) do |length, key|
+ key.length > length ? key.length : length
+ end
+ end
+end
+class Metadata
+ def output(tag, val, spacing = 2)
puts ' ' + tag + ' ' * spacing + val
end
end
@@ -33,7 +37,7 @@ class VorbisComment < Metadata
@tags.sort.each do |tag, val|
val.each do |val|
- output(tag, val)
+ output(tag, val, 2 + @tags.longest_key_length - tag.length)
end
end
end