Sha256: 274a79f18e61495ee34cd1db776b38294aaa4adf3be2429b129c48574bdff782

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

#  Disc object
class RakeMKV::Disc
  attr_reader :location

  #  Initialize disc
  def initialize(location)
    @location = location
  end

  # Get path from location
  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

  # parse file info from command
  def info
    @info ||= RakeMKV::Parser.new(command.info)
  end

  #  Transcode information on disc
  def transcode!(options = {})
    destination = options[:destination] || RakeMKV.config.destination
    title_id = options[:title_id] || titles.longest.id
    command.mkv(title_id, destination)
  end

  # Get titles for disc
  def titles
    RakeMKV::Titles.new(build_titles)
  end

  #  Meta disc information
  def method_missing(method, *args)
    info.cinfo[method.to_sym] || super
  end

  private

  def command
    RakeMKV::Command.new(path)
  end

  def build_titles
    info.tinfo.each_with_index.map do |title, title_id|
      RakeMKV::Title.new(title_id, title)
    end
  end

  def check_directory!(destination)
    unless File.directory? destination
      raise StandardError
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rakemkv-0.2.0 lib/rakemkv/disc.rb