class Dotfiler::Path
Public Class Methods
new(raw_path, expand: true)
click to toggle source
# File lib/dotfiler/path.rb, line 7 def initialize(raw_path, expand: true) @path = raw_path.nil? ? "" : raw_path @full_path = Pathname.new(raw_path) @full_path = @full_path.expand_path if expand == true end
Public Instance Methods
<=>(other_path)
click to toggle source
# File lib/dotfiler/path.rb, line 13 def <=>(other_path) self.full <=> other_path.full end
children()
click to toggle source
# File lib/dotfiler/path.rb, line 45 def children @full_path.children.map { |child| self.class.new(child.to_s) } end
contains?(other_path)
click to toggle source
# File lib/dotfiler/path.rb, line 33 def contains?(other_path) other_path = self.class.new(other_path) if other_path.is_a?(String) children.any? { |child| child == other_path } end
dir?()
click to toggle source
# File lib/dotfiler/path.rb, line 69 def dir? File.directory?(@full_path) end
exists?()
click to toggle source
# File lib/dotfiler/path.rb, line 61 def exists? File.exists?(self.to_s) end
file?()
click to toggle source
# File lib/dotfiler/path.rb, line 65 def file? !dir? && File.file?(@full_path) end
full()
click to toggle source
# File lib/dotfiler/path.rb, line 17 def full @full_path end
join(*paths)
click to toggle source
# File lib/dotfiler/path.rb, line 25 def join(*paths) new_path = @full_path paths.each { |path| new_path = new_path.join(path) } self.class.new(new_path.to_s) end
name()
click to toggle source
# File lib/dotfiler/path.rb, line 57 def name @full_path.basename end
parent_dir()
click to toggle source
# File lib/dotfiler/path.rb, line 49 def parent_dir self.class.new(@full_path.parent.to_s) end
real()
click to toggle source
# File lib/dotfiler/path.rb, line 53 def real @full_path.realpath end
symlink?()
click to toggle source
# File lib/dotfiler/path.rb, line 73 def symlink? File.symlink?(@full_path) end
to_s()
click to toggle source
# File lib/dotfiler/path.rb, line 21 def to_s @full_path.to_s end
within?(other_path)
click to toggle source
# File lib/dotfiler/path.rb, line 39 def within?(other_path) other_path = self.class.new(other_path) if other_path.is_a?(String) other_path.children.any? { |child| child == self } end