Skip to content

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

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.

See also #blksize #blocks #birthtime #chardev? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0