Ruby 2.5.0 リファレンスマニュアル > ライブラリ一覧 > stringioライブラリ > StringIOクラス > bytes
each_byte {|ch| ... } -> self
[permalink][rdoc]each_byte -> Enumerator
bytes {|ch| ... } -> self
bytes -> Enumerator
自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。
require "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
[SEE_ALSO] IO#each_byte