Method: Archive#each
- Defined in:
- ext/archive.cpp
#each ⇒ Object #each ⇒ Object
Iterates through the archive and yields each entry as an Archive::Entry object. The second parameter contains the data of that entry, so you don’t have to extract it only to read what’s in it.
Return value
If a block is given, returns an array of Archive::Entry objects, otherwise an enumerator.
Example
a.each{|entry| p entry.path}
a.each{|entry, data| puts "'#{entry.path}' contains '#{data}'"}
Output:
"file1.txt"
"file2.txt"
'file1.txt' contains 'I am file1!'
'file2.txt' contains 'I am file2!'
421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'ext/archive.cpp', line 421
VALUE Archive_each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
struct archive *a = archive_read_new();
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
archive_read_support_format_raw(a);
int error=Archive_read_ruby(self,a);
if(error==ARCHIVE_OK)
return RB_ENSURE(Archive_each_block,a,Archive_read_block_ensure,a);
return Qnil;
}
|