ファイルから3行ずつ取ってくる
lines = "" File.open(file_name) do |f| i = 0 while l = f.gets lines += l.strip lines += "\n" if i%3==2 i += 1 end end
もっとRubyっぽい書き方はできないものだろうか..
lines = "" File.open(file_name) do |f| i = 0 while l = f.gets lines += l.strip lines += "\n" if i%3==2 i += 1 end end
もっとRubyっぽい書き方はできないものだろうか..