Sha256: 33d9b116bb528a4b5062b118df7e249f2e3f1030e456d433325954c60516f032

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

dir = File.dirname(__FILE__)

require "#{dir}/../lib/doc_storage"

# Create a new document with two parts
document = DocStorage::MultiPartDocument.new([
  DocStorage::SimpleDocument.new(
    {
      "Title"    => "Finishing the documentation",
      "Priority" => "urgent"
    },
    "We should finish the documentation ASAP."
  ),
  DocStorage::SimpleDocument.new(
    {
      "Title"    => "Finishing the code",
      "Priority" => "more urgent"
    },
    "But we should finish the code first!"
  ),
])

# Parse a file
document = File.open("#{dir}/multipart.txt", "r") do |f|
  DocStorage::MultiPartDocument.parse(f)
end

# Document manipulation
document.parts << DocStorage::SimpleDocument.new(
  {
    "Author"   => "Middle man",
    "Datetime" => "2009-11-01 21:15:33",
  },
  "I think your article is neither good nor bad."
)

# Save the modified document
File.open("#{dir}/multipart_modified.txt", "w") do |f|
  f.write(document)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doc_storage-0.9 examples/multipart.rb