Method: File::Stat#chardev?

Defined in:
file.c

#chardev?Boolean

Returns true if the file is a character device, false if it isn’t or if the operating system doesn’t support this feature.

File.stat("/dev/tty").chardev?   #=> true

Returns:

  • (Boolean)

5863
5864
5865
5866
5867
5868
5869
# File 'file.c', line 5863

static VALUE
rb_stat_c(VALUE obj)
{
    if (S_ISCHR(get_stat(obj)->st_mode)) return Qtrue;

    return Qfalse;
}