Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

File::Stat#mode

() -> ::Integer
stat.mode → integer

Returns an integer representing the permission bits of stat. The meaning of the bits is platform dependent; on Unix systems, see stat(2).

Example
File.chmod(0644, "testfile")   #=> 1
s = File.stat("testfile")
sprintf("%o", s.mode)          #=> "100644"
See also #inspect #mtime #ino #nlink also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0