class MediaInfo::Base
Attributes
streams[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/media_info/base.rb, line 5 def initialize(filename) check_file(filename) @streams = Parser.call(filename) end
Public Instance Methods
audio()
click to toggle source
# File lib/media_info/base.rb, line 81 def audio audios.first end
audio?()
click to toggle source
# File lib/media_info/base.rb, line 25 def audio? stream?(:audio) end
audios()
click to toggle source
# File lib/media_info/base.rb, line 53 def audios search_stream(:audio) end
general()
click to toggle source
# File lib/media_info/base.rb, line 73 def general generals.first end
general?()
click to toggle source
# File lib/media_info/base.rb, line 17 def general? stream?(:general) end
generals()
click to toggle source
# File lib/media_info/base.rb, line 45 def generals search_stream(:general) end
image()
click to toggle source
# File lib/media_info/base.rb, line 89 def image images.first end
image?()
click to toggle source
# File lib/media_info/base.rb, line 33 def image? stream?(:image) end
images()
click to toggle source
# File lib/media_info/base.rb, line 61 def images search_stream(:image) end
other()
click to toggle source
# File lib/media_info/base.rb, line 97 def other others.first end
other?()
click to toggle source
# File lib/media_info/base.rb, line 41 def other? stream?(:other) end
others()
click to toggle source
# File lib/media_info/base.rb, line 69 def others search_stream(:other) end
streams_types()
click to toggle source
# File lib/media_info/base.rb, line 11 def streams_types streams.map do |stream| stream.class::TYPE end.uniq end
text()
click to toggle source
# File lib/media_info/base.rb, line 85 def text texts.first end
text?()
click to toggle source
# File lib/media_info/base.rb, line 29 def text? stream?(:text) end
texts()
click to toggle source
# File lib/media_info/base.rb, line 57 def texts search_stream(:text) end
video()
click to toggle source
# File lib/media_info/base.rb, line 77 def video videos.first end
video?()
click to toggle source
# File lib/media_info/base.rb, line 21 def video? stream?(:video) end
videos()
click to toggle source
# File lib/media_info/base.rb, line 49 def videos search_stream(:video) end
Private Instance Methods
check_file(file_path)
click to toggle source
# File lib/media_info/base.rb, line 111 def check_file(file_path) raise ArgumentError, "#{file_path} does not exist or is not local file" unless File.exist?(file_path) end
search_stream(type)
click to toggle source
# File lib/media_info/base.rb, line 107 def search_stream(type) streams.select { |stream| stream.class::TYPE == type } end
stream?(type)
click to toggle source
# File lib/media_info/base.rb, line 103 def stream?(type) streams.any? { |stream| stream.class::TYPE == type } end