Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > File::Statクラス

class File::Stat

クラスの継承リスト: File::Stat < Comparable < Object < Kernel < BasicObject

要約

ファイルの情報を格納したオブジェクトのクラス。

FileTest に同名のモジュール関数がある場合はそれと同じ働きをします。ただ、 ファイル名を引数に取るかわりに Stat 自身について判定する点が違います。

p File::Stat.new($0).directory? #=> false
p FileTest.directory?($0) #=> false

以下の属性メソッドは、システムによってサポートされていない場合 0 が返ります。 1.8.0 以降では nil が返ります。

dev         デバイス番号(ファイルシステム)
dev_major   dev の major 番号部
dev_minor   dev の minor 番号部
ino         i-node 番号
mode        ファイルモード
nlink       ハードリンクの数
uid         オーナーのユーザID
gid         オーナーのグループID
rdev        デバイスタイプ(スペシャルファイルのみ)
rdev_major  rdev の major 番号部
rdev_minor  rdev の minor 番号部
size        ファイルサイズ(バイト単位)
blksize     望ましいI/Oのブロックサイズ
blocks      割り当てられているブロック数
atime       最終アクセス時刻
mtime       最終更新時刻
ctime       最終状態変更時刻(状態の変更とは chmod などによるもので、Unix では i-node の変更を意味します)

特異メソッド

定義 説明
new(path) -> File::Stat

path に関する File::Stat オブジェクトを生成して返します。 File.stat と同じです。

インスタンスメソッド

定義 説明
self <=> o -> Fixnum | nil

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

atime -> Time

最終アクセス時刻を返します。

blksize -> Integer

望ましいI/Oのブロックサイズを返します。

blockdev? -> bool

ブロックスペシャルファイルの時に真を返します。

blocks -> Integer

割り当てられているブロック数を返します。

chardev? -> bool

キャラクタスペシャルファイルの時に真を返します。

ctime -> Time

最終状態変更時刻を返します。 (状態の変更とは chmod などによるもので、Unix では i-node の変更を意味します)

dev -> String

デバイス番号(ファイルシステム)を返します。

dev_major -> Integer

dev の major 番号部を返します。

dev_minor -> Integer

dev の minor 番号部を返します。

directory? -> bool

ディレクトリの時に真を返します。

executable? -> bool

実効ユーザ/グループIDで実行できる時に真を返します。

executable_real? -> bool

実ユーザ/グループIDで実行できる時に真を返します。

file? -> bool

通常ファイルの時に真を返します。

ftype -> String

ファイルのタイプを表す文字列を返します。文字列は以下のうちの いずれかです。

gid -> Integer

オーナーのグループIDを返します。

grpowned? -> bool

グループIDが実効グループIDと等しい時に真を返します。

ino -> Integer

i-node 番号を返します。

mode -> Integer

ファイルモードを返します。

mtime -> Time

最終更新時刻を返します。

nlink -> Integer

ハードリンクの数を返します。

owned? -> bool

自分のものである時に真を返します。

pipe? -> bool

無名パイプおよび名前つきパイプ(FIFO)の時に真を返します。

rdev -> Integer

デバイスタイプ(スペシャルファイルのみ)を返します。

rdev_major -> Integer

rdev の major 番号部を返します。

rdev_minor -> Integer

rdev の minor 番号部を返します。

readable? -> bool

読み込み可能な時に真を返します。

readable_real? -> bool

実ユーザ/実グループによって読み込み可能な時に真を返します。

setgid? -> bool

setgidされている時に真を返します。

setuid? -> bool

setuidされている時に真を返します。

size -> Integer

ファイルサイズ(バイト単位)を返します。

size? -> Integer | nil

サイズが0の時にはnil、それ以外の場合はファイルサイズを返します。

socket? -> bool

ソケットの時に真を返します。

sticky? -> bool

stickyビットが立っている時に真を返します。

symlink? -> false

シンボリックリンクである時に真を返します。 ただし、File::Statは自動的にシンボリックリンクをたどっていくので 常にfalseを返します。

uid -> Integer

オーナーのユーザIDを返します。

world_readable? -> Fixnum | nil

If stat is readable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).

world_writable? -> Fixnum | nil

If stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).

writable? -> bool

書き込み可能な時に真を返します。

writable_real? -> bool

実ユーザ/実グループによって書き込み可能な時に真を返します。

zero? -> bool

サイズが0である時に真を返します。

継承したメソッド

! != < <= == > >= between? === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to