Skip to content

Commit c6d3287

Browse files
committed
[DOC] Doc for Pathname#+
1 parent 056d6ff commit c6d3287

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

lib/pathname_builtin.rb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -647,20 +647,29 @@ def ascend
647647
end
648648
end
649649

650+
# call-seq:
651+
# self + other -> new_pathname
650652
#
651-
# Appends a pathname fragment to +self+ to produce a new Pathname object.
652-
# Since +other+ is considered as a path relative to +self+, if +other+ is
653-
# an absolute path, the new Pathname object is created from just +other+.
653+
# Returns a new \Pathname object;
654+
# argument +other+ may be a string or another pathname.
654655
#
655-
# p1 = Pathname.new("/usr") # Pathname:/usr
656-
# p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
657-
# p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
656+
# When +other+ specifies a relative path (see #relative?),
657+
# equivalent to <tt>Pathname.new(self.to_s + other.to_s)</tt>:
658658
#
659-
# # / is aliased to +.
660-
# p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
661-
# p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
659+
# pn = Pathname.new("/usr") # => #<Pathname:/usr>
660+
# pn + 'bin/ruby' # => #<Pathname:/usr/bin/ruby>
661+
# pn + Pathname.new('bin/ruby') # => #<Pathname:/usr/bin/ruby>
662662
#
663-
# This method doesn't access the file system; it is pure string manipulation.
663+
# When +other+ specifies an absolute path (see #absolute?),
664+
# equivalent to <tt>Pathname.new(other.to_s)</tt>:
665+
#
666+
# pn + Pathname.new('/etc/password') # => #<Pathname:/etc/password>
667+
# pn + '/etc/password' # => #<Pathname:/etc/password>
668+
#
669+
# Does not access the file system, so +other+ need not represent
670+
# an existing (or even a valid) file or directory path:
671+
#
672+
# pn + 'nosuch:ever' # => #<Pathname:/usr/nosuch:ever>
664673
#
665674
def +(other)
666675
other = Pathname.new(other) unless Pathname === other

0 commit comments

Comments
 (0)