Class: MmTool::MmMovieIgnoreList

Inherits:
Object
  • Object
show all
Defined in:
lib/mm_tool/mm_movie_ignore_list.rb

Overview

A list of movie files to ignore during :normal and :all scan types. Will keep the on-file list in sync with the in-memory list.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMmMovieIgnoreList


Initialize




25
26
27
28
29
30
31
32
33
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 25

def initialize
  @ignore_list = []
  if !File.file?(file_path)
    FileUtils.mkdir_p(File.dirname(file_path))
  else
    #noinspection RubyResolve
    @ignore_list = YAML.load(File.read(file_path))
  end
end

Class Method Details

.shared_ignore_listObject


Singleton accessor.




15
16
17
18
19
20
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 15

def self.shared_ignore_list
  unless @self
    @self = self.new
  end
  @self
end

Instance Method Details

#add(path:) ⇒ Object


Add a path to the list, and write list to disk.




52
53
54
55
56
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 52

def add(path:)
  new_list = @ignore_list |= [path]
  @ignore_list = new_list.sort
  File.open(file_path, 'w') { |file| file.write(@ignore_list.to_yaml(options = {:line_width => -1})) }
end

#file_pathObject


The location on the filesystem where the file exists.




38
39
40
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 38

def file_path
  PATH_IGNORE_LIST
end

#include?(path) ⇒ Boolean


Is the given file on the ignore list?


Returns:

  • (Boolean)


45
46
47
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 45

def include?(path)
  @ignore_list.include?(path)
end

#remove(path:) ⇒ Object


Remove a path from the list, and update on disk.




61
62
63
64
# File 'lib/mm_tool/mm_movie_ignore_list.rb', line 61

def remove(path:)
  @ignore_list.delete(path)
  File.open(file_path, 'w') { |file| file.write(@ignore_list.to_yaml(options = {:line_width => -1})) }
end