Class: Tagmv::PrunePath

Inherits:
Object
  • Object
show all
Defined in:
lib/tagmv/prune_path.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PrunePath

Returns a new instance of PrunePath.



4
5
6
# File 'lib/tagmv/prune_path.rb', line 4

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/tagmv/prune_path.rb', line 3

def path
  @path
end

Class Method Details

.prune_tag_dirsObject



20
21
22
23
24
# File 'lib/tagmv/prune_path.rb', line 20

def self.prune_tag_dirs
  Find.find(Tagmv::Filesystem.root).reverse_each do |path|
    Tagmv::PrunePath.new(path).rmdir
  end
end

Instance Method Details

#empty_dir?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/tagmv/prune_path.rb', line 12

def empty_dir?
  FileTest.directory?(path) && Dir.entries(path) == ['.', '..']
end

#rmdirObject



16
17
18
# File 'lib/tagmv/prune_path.rb', line 16

def rmdir
  Dir.rmdir(path) if tag_dir? && empty_dir?
end

#tag_dir?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/tagmv/prune_path.rb', line 8

def tag_dir?
  path =~ /..-$/ && path !~ Tagmv::Tree.false_tag_regex
end