Skip to content
instance method

IO#each_byte

() { (::Integer byte) -> void } -> self
() -> ::Enumerator[::Integer, self]
each_byte {|byte| ... } → self
each_byte → enumerator

Calls the given block with each byte (0..255) in the stream; returns self. See Byte IO.

Example
f = File.new('t.rus')
a = []
f.each_byte {|b| a << b }
a # => [209, 130, 208, 181, 209, 129, 209, 130]
f.close

Returns an Enumerator if no block is given.

Related: IO#each_char, IO#each_codepoint.

See also #each #each_char #cursor_up #each_codepoint also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0