Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#file?
() -> bool
file? → true or false
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 2434
def file?() FileTest.file?(@path) end
Returns whether the entry at the path in self exists and is a regular file; see Pathname#ftype:
Example
Pathname('/etc/passwd').file? # => true Pathname('/etc').file? # => false Pathname('nosuch').file? # => false