Class: MkvToolNix::Types::Info::MkvContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/mkvtoolnix/types/info/mkv_container.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, file_name:, format_version:, type:, is_supported:, is_recognized:, container_type:, date_utc:, duration_in_nano:, is_providing_timestamps:, mux_application:, segment_uid:, writing_application:, attachments:, videos:, audios:, subtitles:) ⇒ MkvContainer

Returns a new instance of MkvContainer.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 34

def initialize(title:, file_name:, format_version:, type:, is_supported:, is_recognized:, container_type:,
               date_utc:, duration_in_nano:, is_providing_timestamps:, mux_application:, segment_uid:,
               writing_application:, attachments:, videos:, audios:, subtitles:)
  @title = title
  @file_name = file_name
  @format_version = format_version
  @type = type
  @is_supported = is_supported
  @is_recognized = is_recognized
  @container_type = container_type
  @date_utc = date_utc
  @duration_in_secs = duration_in_nano.to_f / 1_000_000_000
  @is_providing_timestamps = is_providing_timestamps
  @mux_application = mux_application
  @segment_uid = segment_uid
  @writing_application = writing_application
  @attachments = attachments
  @videos = videos
  @audios = audios
  @subtitles = subtitles
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def attachments
  @attachments
end

#audiosObject

Returns the value of attribute audios.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def audios
  @audios
end

#container_typeObject

Returns the value of attribute container_type.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def container_type
  @container_type
end

#date_utcObject

Returns the value of attribute date_utc.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def date_utc
  @date_utc
end

#duration_in_secsObject

Returns the value of attribute duration_in_secs.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def duration_in_secs
  @duration_in_secs
end

#file_nameObject

Returns the value of attribute file_name.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def file_name
  @file_name
end

#format_versionObject

Returns the value of attribute format_version.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def format_version
  @format_version
end

#is_providing_timestampsObject

Returns the value of attribute is_providing_timestamps.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def is_providing_timestamps
  @is_providing_timestamps
end

#is_recognizedObject

Returns the value of attribute is_recognized.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def is_recognized
  @is_recognized
end

#is_supportedObject

Returns the value of attribute is_supported.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def is_supported
  @is_supported
end

#mux_applicationObject

Returns the value of attribute mux_application.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def mux_application
  @mux_application
end

#segment_uidObject

Returns the value of attribute segment_uid.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def segment_uid
  @segment_uid
end

#subtitlesObject

Returns the value of attribute subtitles.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def subtitles
  @subtitles
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def title
  @title
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def type
  @type
end

#videosObject

Returns the value of attribute videos.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def videos
  @videos
end

#writing_applicationObject

Returns the value of attribute writing_application.



8
9
10
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 8

def writing_application
  @writing_application
end

Class Method Details

.create(hash) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mkvtoolnix/types/info/mkv_container.rb', line 12

def self.create(hash)
  container = hash['container']
  props = container['properties']
  attachments = hash['attachments'].map { |it| Attachment.create(it) }
  tracks = hash['tracks']
  video_hash = tracks.select { |it| it['type'] == 'video' }
  videos = video_hash.nil? ? [] : video_hash.map { |it| Video.create(it) }
  audio_hash = tracks.select { |it| it['type'] == 'audio' }
  audios = audio_hash.nil? ? [] : audio_hash.map { |it| Audio.create(it) }
  subtitle_hash = tracks.select { |it| it['type'] == 'subtitles' }
  subtitles = subtitle_hash.nil? ? [] : subtitle_hash.map { |it| Subtitle.create(it) }

  new(title: props['title'], file_name: hash['file_name'],
      format_version: hash['identification_format_version'], type: container['type'],
      is_supported: container['supported'], is_recognized: container['recognized'],
      container_type: props['container_type'], date_utc: props['date_utc'],
      duration_in_nano: props['duration'], is_providing_timestamps: props['is_providing_timestamps'],
      mux_application: props['muxing_application'], segment_uid: props['segment_uid'],
      writing_application: props['writing_application'], attachments: attachments, videos: videos,
      audios: audios, subtitles: subtitles)
end