ruby file
code:_.rb
File.foreach("a.txt") do |line| # read
p line
end
File.open('b.txt','w') do |f| # write
f.puts('foo')
f.puts('hoo')
end
# 追記
file = File.open('path', 'a')
file.puts 'foo'
file.close
# 読み込み
p File.read('a.txt')
File.basename("/app/controller/foo.rb") # foo.rbだけ表示