Class: Omnizip::Temp::ArchiveHelper
- Inherits:
-
Object
- Object
- Omnizip::Temp::ArchiveHelper
- Defined in:
- lib/omnizip/temp.rb
Overview
Helper class for temp archive operations
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#add_file(name, data = nil, &block) ⇒ Object
Add file to archive.
-
#initialize(path, format) ⇒ ArchiveHelper
constructor
A new instance of ArchiveHelper.
Constructor Details
#initialize(path, format) ⇒ ArchiveHelper
Returns a new instance of ArchiveHelper.
119 120 121 122 |
# File 'lib/omnizip/temp.rb', line 119 def initialize(path, format) @path = path @format = format end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
117 118 119 |
# File 'lib/omnizip/temp.rb', line 117 def format @format end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
117 118 119 |
# File 'lib/omnizip/temp.rb', line 117 def path @path end |
Instance Method Details
#add_file(name, data = nil, &block) ⇒ Object
Add file to archive
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/omnizip/temp.rb', line 127 def add_file(name, data = nil, &block) data = yield if block case format when :zip Omnizip::Zip::File.create(path) do |zip| zip.add(name) { data } end end end |