class MultimediaParadise::Video::CheckNumbers
Constants
- DATASET_CONTAINING_ALL_VIDEOS
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( check_this_entity = Dir.pwd, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/check_numbers.rb, line 46 def initialize( check_this_entity = Dir.pwd, run_already = true ) reset if block_given? yielded = yield case yielded when :do_not_use_opn @do_use_opn = false end end set_check_this_entity(check_this_entity) run if run_already end
Public Instance Methods
check_this_entity?()
click to toggle source
#¶ ↑
check_this_entity?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/check_numbers.rb, line 87 def check_this_entity? @check_this_entity end
Also aliased as: entity?
check_whether_this_file_is_included(i)
click to toggle source
#¶ ↑
check_whether_this_file_is_included
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/check_numbers.rb, line 145 def check_whether_this_file_is_included(i) # ======================================================================= # # Chop off '/' if they are part of the input. # ======================================================================= # i = File.basename(i) if i.include? '/' # Sanitize the input. if i.include? '_VHS-RIP' i.sub!(/_VHS-RIP/,'') end if i.include? '_' # <- Only these are assumed to be correct. dataset = dataset? splitted = i.split('_') position = splitted.first.to_i if dataset.has_key? position title = dataset[position]['title'] compact_title = title.delete(' ') n_pad = 45 if i.delete('_').include? compact_title opnn; e 'Yes, '+sfancy(i.ljust(n_pad))+' is included. The position '\ 'is '+simp(position.to_s.rjust(3))+'.' else # Here when the input was NOT found. opnn; e ' No, '+sfancy(i.ljust(n_pad))+' is '+swarn('NOT')+ ' included. The position is '+simp(position.to_s.rjust(3))+'.' e '---' pp i pp compact_title e '---' exit end else opnne swarn('The position ')+sfancy(position)+swarn(' was not found in '\ 'the dataset.')+' This is the input `'+simp(i)+'`.' opnne 'Perhaps it can be deleted.' exit # Easier to exit here, then fix the problem. end end end
dataset?()
click to toggle source
handle_given_input()
click to toggle source
#¶ ↑
handle_given_input
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/check_numbers.rb, line 101 def handle_given_input _ = entity? if File.directory? _ # ======================================================================= # # If it is a directory, we obtain all files. # ======================================================================= # these_video_files = select_only_video_files_from(Dir[_+'*']) # ======================================================================= # # Sanitize them via File.basename() next. # ======================================================================= # these_video_files.map! {|entry| File.basename(entry) } # ======================================================================= # # Sort them: # ======================================================================= # these_video_files = these_video_files.sort_by {|entry| first_number_part = entry.split('_').first.to_i first_number_part } these_video_files.each {|entry| check_whether_this_file_is_included(entry) } opnne 'All '+simp(these_video_files.size.to_s)+' videos are correct '\ 'from the names alone, at the least.' elsif File.file? _ check_whether_this_file_is_included(_) else opnn; e 'No idea how to proceed with '+simp(_)+'.' unless File.exist? _ opnn; e 'The input does not exist. Perhaps you have' opnn; e 'misspelled the name?' end end end
opnn()
click to toggle source
opnne(i)
click to toggle source
reset()
click to toggle source
run()
click to toggle source
select_only_video_files_from(array)
click to toggle source
set_check_this_entity(i = '')
click to toggle source
#¶ ↑
set_check_this_entity
¶ ↑
The “entity” can be either a directory or a file.
#¶ ↑
# File lib/multimedia_paradise/video/check_numbers.rb, line 75 def set_check_this_entity(i = '') i = i.first if i.is_a? Array i = i.to_s.dup if File.directory? i i << '/' unless i.end_with? '/' end @check_this_entity = i end