class Mkv_File

Attributes

audio[R]
path[R]
subtitles[R]

Public Class Methods

new(path) click to toggle source
# File bin/mkvtoolhelper, line 105
def initialize path
        @path = path
        identify!
end

Public Instance Methods

identify!() click to toggle source
# File bin/mkvtoolhelper, line 110
def identify!
        json = invoke_and_get_output %W{mkvmerge --identify-verbose -J #{@path}}
        @data = JSON.parse json
        get_audio_tracks!
        get_subtitle_tracks!
end
to_s() click to toggle source
# File bin/mkvtoolhelper, line 117
def to_s
        "#<Mkv_File::#{@path}>"
end

Private Instance Methods

get_audio_tracks!() click to toggle source
# File bin/mkvtoolhelper, line 130
def get_audio_tracks!
        @audio = []
        @data['tracks'].select { |t| t['type'] == 'audio' }.each do |t|
                @audio << Audio_Track.new(t)
        end
end
get_subtitle_tracks!() click to toggle source
# File bin/mkvtoolhelper, line 137
def get_subtitle_tracks!
        @subtitles = []
        @data['tracks'].select { |t| t['type'] == 'subtitles' }.each do |t|
                @subtitles << Subtitles_Track.new(t)
        end
end
invoke_and_get_output(args) click to toggle source
# File bin/mkvtoolhelper, line 124
def invoke_and_get_output args
        o, s = Open3.capture2e(*args)
        raise "Invoke failed: #{o}" unless s.success?
        o
end