Ruby 文件IO 2015/12/05 20231 class Filetest attr_accessor :filename def initialize(filename) @filename = filename end def puts_file File.open(@filename, "r") do |file| while line = file.gets puts line end end end end file = Filetest.new("test") file.puts_file