Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Ruby | File | atime

概要

File.atime

詳細

指定ファイルの最終アクセス時刻を返却する

サンプル

コード
# encoding: utf-8

def create_file(filename, contents)
  File.open(filename, 'w:utf-8') do |f|
    f.print contents
  end
end

filename = 'sample.txt'

create_file filename, <<EOS
内容1_1
内容1_2
内容1_3
EOS
puts File.atime('sample.txt')
出力
2014-01-04 10:38:10 +0900