class RakeMKV::Disc
Disc
object
Constants
- DEFAULT_MINLENGTH
Attributes
destination[R]
location[R]
minlength[R]
parser_class[R]
Public Class Methods
new( location:, destination: Dir.pwd, minlength: DEFAULT_MINLENGTH, parser_class: RakeMKV::Parser )
click to toggle source
Initialize disc
# File lib/rakemkv/disc.rb, line 8 def initialize( location:, destination: Dir.pwd, minlength: DEFAULT_MINLENGTH, parser_class: RakeMKV::Parser ) @location = location @destination = destination @minlength = minlength @parser_class = parser_class end
Public Instance Methods
destination_with_name()
click to toggle source
# File lib/rakemkv/disc.rb, line 60 def destination_with_name File.join(destination, filesafe_name) end
filesafe_name()
click to toggle source
# File lib/rakemkv/disc.rb, line 46 def filesafe_name info.cinfo[:name].downcase.gsub(/[\/ ]/ , "_") end
info()
click to toggle source
parse file info from command
# File lib/rakemkv/disc.rb, line 36 def info @info ||= parser_class.new command.info(arguments) end
method_missing(method, *args)
click to toggle source
Meta disc information
Calls superclass method
# File lib/rakemkv/disc.rb, line 56 def method_missing(method, *args) info.cinfo[method.to_sym] || super end
path()
click to toggle source
Get path from location
# File lib/rakemkv/disc.rb, line 21 def path if location =~ /^\/dev/ "dev:#{location}" elsif location =~ /iso$/ "iso:#{location}" elsif location.is_a?(Integer) "disc:#{location}" elsif location =~ /^disc/ location else raise RuntimeError end end
titles()
click to toggle source
Get titles for disc
# File lib/rakemkv/disc.rb, line 51 def titles RakeMKV::Titles.new(build_titles) end
transcode!(title_id: titles.longest.id)
click to toggle source
Transcode information on disc
# File lib/rakemkv/disc.rb, line 41 def transcode!(title_id: titles.longest.id) check_and_create_destination command.mkv(title_id, destination_with_name, arguments) end
Private Instance Methods
arguments()
click to toggle source
# File lib/rakemkv/disc.rb, line 90 def arguments { minlength: minlength }.compact end
build_titles()
click to toggle source
# File lib/rakemkv/disc.rb, line 78 def build_titles info.tinfo.each_with_index.map do |title, title_id| RakeMKV::Title.new(title_id, title) end end
check_and_create_destination()
click to toggle source
# File lib/rakemkv/disc.rb, line 72 def check_and_create_destination if !Dir.exists?(destination_with_name) Dir.mkdir(destination_with_name) end end
check_directory!(destination)
click to toggle source
# File lib/rakemkv/disc.rb, line 84 def check_directory!(destination) unless File.directory? destination raise StandardError end end
command()
click to toggle source
# File lib/rakemkv/disc.rb, line 68 def command RakeMKV::Command.new(path: path) end