Class: Restforce::Bulk::Zipper
- Inherits:
-
Object
- Object
- Restforce::Bulk::Zipper
- Defined in:
- lib/restforce/bulk/zipper.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#files_mapping ⇒ Object
Returns the value of attribute files_mapping.
Instance Method Summary collapse
-
#initialize(files_mapping, content_type = :zip_xml) ⇒ Zipper
constructor
A new instance of Zipper.
- #zip ⇒ Object
Constructor Details
#initialize(files_mapping, content_type = :zip_xml) ⇒ Zipper
Returns a new instance of Zipper.
6 7 8 9 |
# File 'lib/restforce/bulk/zipper.rb', line 6 def initialize(files_mapping, content_type=:zip_xml) self.files_mapping = files_mapping self.content_type = content_type end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
4 5 6 |
# File 'lib/restforce/bulk/zipper.rb', line 4 def content_type @content_type end |
#files_mapping ⇒ Object
Returns the value of attribute files_mapping.
4 5 6 |
# File 'lib/restforce/bulk/zipper.rb', line 4 def files_mapping @files_mapping end |
Instance Method Details
#zip ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/restforce/bulk/zipper.rb', line 11 def zip ::Zip::File.open(output_filename, ::Zip::File::CREATE) do |zip_file| zip_file.get_output_stream('request.txt') do |io| io.write builder.create_request_txt(files_mapping) end files_mapping.each do |mapping| zip_file.add(mapping[:filename], mapping[:full_filename]) end end output_filename end |