Sha256: f437cb6d091ab8acacc681b090e3cb0c2318c8b50cd4cc49f1ab5e4d2009fd57
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
# frozen_string_literal: true require 'pathname/extensions' class Pathname module Extensions module Partial def self.included(host) host.load_extensions :explode super end # Extract a partial path from the path. Include +n+ directories from the # front end (left hand side) if +n+ is positive. Include |+n+| # directories from the back end (right hand side) if +n+ is negative. def partial(n) dirs = dirname.explode partial_dirs = if n.positive? dirs[0...n] elsif n.negative? dirs.reverse[0...-n].reverse else HERE end Pathname(File.join(partial_dirs)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-files-0.2.0 | lib/pathname/extensions/partial.rb |