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
file.c
View on GitHub ↗
static VALUE
rb_stat_c(VALUE obj)
{
if (S_ISCHR(get_stat(obj)->ST_(mode))) return Qtrue;
return Qfalse;
}
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.