Sha256: 3fa9a9c34ccc75d5092e547f7c93804bf014db0cd33dc24690bae0d2dd5173ed
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
# frozen_string_literal: true require "pathname" module Refinements module Pathnames refine Pathname do def name basename extname end def copy to destination = to.directory? ? to.join(basename) : to read.then { |content| destination.write content } self end def extensions basename.to_s.split(/(?=\.)+/).tap(&:shift) end def relative_parent_from root relative_path_from(root).parent end def make_ancestors dirname.mkpath self end def rewrite read.then { |content| write yield(content) if block_given? } self end def touch at: Time.now exist? ? utime(at, at) : write("") self end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinements-7.3.0 | lib/refinements/pathnames.rb |