From: Kazuhiro NISHIYAMA Date: 2001-03-17T08:20:34+09:00 Subject: [ruby-list:28814] fgets C言語のfgetsのようなサイズ制限付きのgetsをしようとすると 下のように少しずつ読み込んで自分でチェックするしか無いの でしょうか? class IO def fgets(limit, rs=$/) str = ''; ch = nil re = /#{Regexp.quote(rs)}\z/ while str.size < limit && ch = getc str.concat ch return str if re === str end str end end -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA)