summaryrefslogtreecommitdiff
path: root/omptagger
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-08 23:13:42 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-08 23:13:42 -0700
commitd6be58113cd53de5c64ddec97fe525dbc3bed421 (patch)
tree896a93adb7091100c2080142cb4ea9a6a7a1859e /omptagger
parent8fa8278f79c023e9bba8324b08b990e71e4bed36 (diff)
downloadomptagger-d6be58113cd53de5c64ddec97fe525dbc3bed421.tar.gz
omptagger-d6be58113cd53de5c64ddec97fe525dbc3bed421.tar.xz
Improve output spacing code.
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