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#chardev?

() -> bool
chardev? → true or false

Returns whether the entry in the snapshot in self is a character device (i.e., a sequential-access device):

Example
File.stat('/dev/tty').chardev?     # => true
File.stat('/dev/null').chardev?    # => true
File.stat('/dev/nvme0n1').chardev? # => false
File.stat('/dev/loop0').chardev?   # => false

The returned value is filesystem-dependent; on Windows, always false.

See also #blocks #ctime #blockdev? #dev also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0