instance method
FileTest#chardev?
(::path | ::io file_name) -> bool
File.chardev?(filepath) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_chardev_p(VALUE obj, VALUE fname)
{
#ifndef S_ISCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
if (S_ISCHR(st.st_mode)) return Qtrue;
return Qfalse;
}
Returns true if filepath points to a character device, false otherwise.
Example
File.chardev?($stdin) # => true File.chardev?('t.txt') # => false