module Build::URI::Base
Public Instance Methods
+(other)
click to toggle source
# File lib/build/uri/base.rb, line 53 def + other merge(URI[other]) end
basename()
click to toggle source
# File lib/build/uri/base.rb, line 65 def basename clone.path = self.path.rpartition(SEPARATOR).last end
dirname()
click to toggle source
# File lib/build/uri/base.rb, line 57 def dirname clone = self.dup clone.path = self.path.rpartition(SEPARATOR).first return clone end
merge(other, directory: true)
click to toggle source
@attr directory [Boolean] If true, we consider every path to represent a directory, even if there is no trailing slash. If false, basename of self will be ignored when joining.
# File lib/build/uri/base.rb, line 27 def merge(other, directory: true) if self.path.nil? || other.absolute? return other else clone = self.dup if other.path.start_with?(SEPARATOR) clone.path = other.path elsif directory # We try to avoid ending up with more than one slash: if self.path.end_with?(SEPARATOR) clone.path = [self.path, other.path].join else clone.path = [self.path, other.path].join(SEPARATOR) end else # The basename of a non-directory path is ignored when merged. dirname, _, basename = self.path.rpartition(SEPARATOR) clone.path = [dirname, other.path].join(SEPARATOR) end return clone.freeze end end