Class: EmailDoc::Documents
- Inherits:
-
Object
- Object
- EmailDoc::Documents
- Defined in:
- lib/email_doc/documents.rb
Instance Method Summary collapse
- #append(context, mail, example) ⇒ Object
-
#initialize ⇒ Documents
constructor
A new instance of Documents.
- #write ⇒ Object
Constructor Details
#initialize ⇒ Documents
Returns a new instance of Documents.
5 6 7 |
# File 'lib/email_doc/documents.rb', line 5 def initialize @table = Hash.new {|table, key| table[key] = []} end |
Instance Method Details
#append(context, mail, example) ⇒ Object
9 10 11 12 |
# File 'lib/email_doc/documents.rb', line 9 def append(context, mail, example) document = EmailDoc::Document.new(context.clone, mail.clone, example.clone) @table[document.pathname] << document end |
#write ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/email_doc/documents.rb', line 14 def write @table.each do |pathname, documents| pathname.parent.mkpath pathname.open("w") do |file| file << documents.map(&:render).join("\n") end end end |