Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#blockdev?

() -> bool
blockdev? => true or false

Returns whether the path in self points to a block device (i.e., a direct-access device):

Example
Pathname('/dev/nvme0n1').blockdev? # => true
Pathname('/dev/loop0').blockdev?   # => true
Pathname('/dev/tty').blockdev?     # => false
Pathname('/dev/null').blockdev?    # => false
Pathname('nosuch').blockdev?       # => false
Pathname($stdin).blockdev?         # => false

The returned value is filesystem-dependent; returns false on Windows or MacOS.

See also #birthtime #chardev? #binwrite #children also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0