Method: ARGF#each_byte
- Defined in:
- io.c
#bytes {|byte| ... } ⇒ Object #bytes ⇒ Object
ARGF.each_byte {|byte| block } -> ARGF
ARGF.each_byte -> an_enumerator
Iterates over each byte of each file in ARGV. A byte is returned as a Fixnum in the range 0..255.
This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last byte of the first file has been returned, the first byte of the second file is returned. The ARGF.filename method can be used to determine the filename of the current byte.
If no block is given, an enumerator is returned instead.
For example:
ARGF.bytes.to_a #=> [35, 32, ... 95, 10]
11251 11252 11253 11254 11255 11256 11257 11258 11259 |
# File 'io.c', line 11251
static VALUE
argf_each_byte(VALUE argf)
{
RETURN_ENUMERATOR(argf, 0, 0);
FOREACH_ARGF() {
argf_block_call(rb_intern("each_byte"), 0, 0, argf);
}
return argf;
}
|