Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Pathname#relative?
relative?
ext/pathname/lib/pathname.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/ext/pathname/lib/pathname.rb, line 248
def relative?
!absolute?
end
The opposite of Pathname#absolute?
It returns false if the pathname begins with a slash.
Example
p = Pathname.new('/im/sure') p.relative? #=> false p = Pathname.new('not/so/sure') p.relative? #=> true
See also
#realpath
#relative_path_from
#realdirpath
#rename
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0