lib/refinements/pathnames.rb in refinements-9.0.2 vs lib/refinements/pathnames.rb in refinements-9.1.0
- old
+ new
@@ -48,10 +48,14 @@
def deep_touch(...) = make_ancestors.touch(...)
def delete = super && self
+ def delete_prefix(pattern) = parent.join %(#{name.sub(/\A#{pattern}/, "")}#{extname})
+
+ def delete_suffix(pattern) = parent.join %(#{name.sub(/#{pattern}\z/, "")}#{extname})
+
def directories pattern = "*", flag: File::FNM_SYSCASE
glob(pattern, flag).select(&:directory?).sort
end
def empty = file? ? (truncate(0) and self) : remove_tree.make_dir
@@ -72,10 +76,10 @@
def make_path
mkpath
self
end
- def name = basename(extname)
+ def name = basename extname
def relative_parent(root_dir) = relative_path_from(root_dir).parent
def remove_dir = exist? ? (rmdir and self) : self