Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
File::Stat#blockdev?
() -> bool
blockdev? → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_b(VALUE obj)
{
#ifdef S_ISBLK
if (S_ISBLK(get_stat(obj)->ST_(mode))) return Qtrue;
#endif
return Qfalse;
}
Returns whether the entry in the snapshot in self is a block device (i.e., a direct-access device):
Example
File.stat('/dev/nvme0n1').blockdev? # => true File.stat('/dev/loop0').blockdev? # => true File.stat('/dev/tty').blockdev? # => false File.stat('/dev/null').blockdev? # => false
The returned value is filesystem-dependent; returns false on Windows or MacOS.