Class: Bestchange::ZipBuilder
- Inherits:
-
Object
- Object
- Bestchange::ZipBuilder
- Defined in:
- lib/bestchange/zip_builder.rb
Constant Summary collapse
- ARCHIVE_DATA_ENCODING =
'ASCII-8BIT'
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(response_body) ⇒ ZipBuilder
constructor
A new instance of ZipBuilder.
Constructor Details
#initialize(response_body) ⇒ ZipBuilder
Returns a new instance of ZipBuilder.
7 8 9 |
# File 'lib/bestchange/zip_builder.rb', line 7 def initialize(response_body) @response_body = response_body end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bestchange/zip_builder.rb', line 11 def call zip_file = Tempfile.new('', encoding: ARCHIVE_DATA_ENCODING) zip_file.write(@response_body) zip_file.rewind if block_given? begin yield zip_file ensure zip_file.close end else zip_file end end |