class RenameGem::Renamer::Path
Attributes
path[R]
pwd[R]
Public Class Methods
new(path, pwd)
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 10 def initialize(path, pwd) @path = Pathname.new(path) @pwd = Pathname.new(pwd) end
Public Instance Methods
build(new_path)
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 23 def build(new_path) pathname = path.dirname.join(new_path) self.class.new(pathname, pwd) end
directories()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 28 def directories absolute_path.children.select(&:directory?).sort.map do |pathname| self.class.new(relative_path(pathname), pwd) end end
directory?()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 44 def directory? absolute_path.directory? end
file?()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 40 def file? absolute_path.file? end
filename()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 19 def filename absolute_path.basename.to_s end
files()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 34 def files absolute_path.children.select(&:file?).sort.map do |pathname| self.class.new(relative_path(pathname), pwd) end end
to_s()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 15 def to_s absolute_path.to_s end
Private Instance Methods
absolute_path()
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 50 def absolute_path pwd.join(path) end
relative_path(pathname)
click to toggle source
# File lib/rename_gem/renamer/path.rb, line 54 def relative_path(pathname) pathname.relative_path_from(pwd) end