End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
File.umask
File.umask() → integer
File.umask(integer) → integer
file.c
View on GitHub ↗
static VALUE
rb_file_s_umask(int argc, VALUE *argv, VALUE _)
{
mode_t omask = 0;
switch (argc) {
case 0:
omask = umask(0);
umask(omask);
break;
case 1:
omask = umask(NUM2MODET(argv[0]));
break;
default:
rb_error_arity(argc, 0, 1);
}
return MODET2NUM(omask);
}
Returns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222 would make a file read-only for everyone.
Example
File.umask(0006) #=> 18 File.umask #=> 6