Sha256: 36459f1e4752a8eb14c24a1f0eaec351c85927c92f727344f11a3b820eecd8ae
Contents?: true
Size: 762 Bytes
Versions: 2
Compression:
Stored size: 762 Bytes
Contents
# Standard Ruby String class. class String # Check if the given string ends with any of the supplied suffixes # @param suffix [String, Array] The suffix to look for. # @return a true value if the string ends with one of the suffixes given. def has_suffix?(suffix) if suffix suffix = [suffix] if suffix.is_a?(String) suffix = suffix.flatten suffix.find {|s| self.end_with?(s)} end end # Return a new string with the suffix (dot character and extension) changed # to the given suffix. # @param suffix [String] The new suffix. def set_suffix(suffix = '') sub(/\.[^.]*$/, suffix) end # Return whether the string represents an absolute filesystem path def absolute_path? self =~ %r{^(/|\w:[\\/])} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rscons-0.3.1 | lib/rscons/monkey/string.rb |
rscons-0.3.0 | lib/rscons/monkey/string.rb |