APIdock / Ruby
/
Browse About
method

root?

v2_1_10 - Show latest stable - Class: Pathname
root?()
public

Predicate method for root directories. Returns true if the pathname consists of consecutive slashes.

It doesn’t access the filesystem. So it may return false for some pathnames which points to roots such as /usr/...

# File ext/pathname/lib/pathname.rb, line 212
  def root?
    !!(chop_basename(@path) == nil && /#{SEPARATOR_PAT}/ =~ @path)
  end

Related methods

  • Instance methods
  • +
  • <=>
  • ==
  • ===
  • absolute?
  • ascend
  • atime
  • basename
  • binread
  • binwrite
  • blockdev?
  • chardev?
  • children
  • chmod
  • chown
  • cleanpath
  • ctime
  • delete
  • descend
  • directory?
  • dirname
  • each_child
  • each_entry
  • each_filename
  • each_line
  • entries
  • eql?
  • executable?
  • executable_real?
  • exist?
  • expand_path
  • extname
  • file?
  • find
  • fnmatch
  • fnmatch?
  • freeze
  • ftype
  • grpowned?
  • hash
  • inspect
  • join
  • lchmod
  • lchown
  • lstat
  • make_link
  • make_symlink
  • mkdir
  • mkpath
  • mountpoint?
  • mtime
  • open
  • opendir
  • owned?
  • parent
  • pipe?
  • read
  • readable?
  • readable_real?
  • readlines
  • readlink
  • realdirpath
  • realpath
  • relative?
  • relative_path_from
  • rename
  • rmdir
  • rmtree
  • root?
  • setgid?
  • setuid?
  • size
  • size?
  • socket?
  • split
  • stat
  • sticky?
  • sub
  • sub_ext
  • symlink?
  • sysopen
  • taint
  • to_path
  • to_s
  • truncate
  • unlink
  • untaint
  • utime
  • world_readable?
  • world_writable?
  • writable?
  • writable_real?
  • write
  • zero?
  • Class methods
  • getwd
  • glob
  • new
  • pwd
  • Private methods
  • privateadd_trailing_separator
  • privatechop_basename
  • privatecleanpath_aggressive
  • privatecleanpath_conservative
  • privatedel_trailing_separator
  • privatehas_trailing_separator?
  • privateplus
  • privateprepend_prefix
  • privatesplit_names
APIdock API Documentation Browser

© 2026 APIdock