Class: MovieOrganizer::MediaList
- Inherits:
-
Object
- Object
- MovieOrganizer::MediaList
- Defined in:
- lib/movie_organizer/media_list.rb
Instance Attribute Summary collapse
-
#file_collection ⇒ Object
Returns the value of attribute file_collection.
Instance Method Summary collapse
-
#initialize(directories = MovieOrganizer.source_directories) ⇒ MediaList
constructor
Walk the source_directories finding all pertinent media files.
- #media?(filename) ⇒ Boolean
- #subtitle?(filename) ⇒ Boolean
- #video?(filename) ⇒ Boolean
Constructor Details
#initialize(directories = MovieOrganizer.source_directories) ⇒ MediaList
Walk the source_directories finding all pertinent media files
10 11 12 13 14 15 16 17 |
# File 'lib/movie_organizer/media_list.rb', line 10 def initialize(directories = MovieOrganizer.source_directories) @file_collection = [] directories.each do |directory| Dir["#{directory}/**/*"].each do |entry| file_collection << entry if media?(entry) end end end |
Instance Attribute Details
#file_collection ⇒ Object
Returns the value of attribute file_collection.
7 8 9 |
# File 'lib/movie_organizer/media_list.rb', line 7 def file_collection @file_collection end |
Instance Method Details
#media?(filename) ⇒ Boolean
19 20 21 |
# File 'lib/movie_organizer/media_list.rb', line 19 def media?(filename) video?(filename) || subtitle?(filename) end |
#subtitle?(filename) ⇒ Boolean
27 28 29 |
# File 'lib/movie_organizer/media_list.rb', line 27 def subtitle?(filename) !MIME::Types.of(filename).map(&:content_type).grep(/(subtitle$|subrip$)/).empty? end |
#video?(filename) ⇒ Boolean
23 24 25 |
# File 'lib/movie_organizer/media_list.rb', line 23 def video?(filename) MIME::Types.of(filename).map(&:media_type).include?('video') end |