lib/signore/signature.rb in signore-0.0.0 vs lib/signore/signature.rb in signore-0.1.0

- old
+ new

@@ -1,12 +1,20 @@ module Signore class Signature < Struct.new :text, :author, :source, :subject, :tags - def display - Wrapper.new(text, meta).display - end - def tagged_with? tag tags and tags.include? tag + end + + def to_s + lines = text.split("\n").map { |line| LovelyRufus::Wrapper.new(line).wrapped 80 } + + if meta + lines << "[#{meta}]" + max = lines.map { |line| line.split "\n" }.flatten.map(&:size).max + lines.last.insert 0, ' ' * (max - meta.size - 2) + end + + lines.join "\n" end private def meta