diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-08 23:13:42 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-08 23:13:42 -0700 |
commit | d6be58113cd53de5c64ddec97fe525dbc3bed421 (patch) | |
tree | 896a93adb7091100c2080142cb4ea9a6a7a1859e /omptagger | |
parent | 8fa8278f79c023e9bba8324b08b990e71e4bed36 (diff) | |
download | omptagger-d6be58113cd53de5c64ddec97fe525dbc3bed421.tar.gz omptagger-d6be58113cd53de5c64ddec97fe525dbc3bed421.tar.xz |
Improve output spacing code.
Diffstat (limited to 'omptagger')
-rwxr-xr-x | omptagger | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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 |