class KodiDedup::MediaFile
Constants
- FORMATS
Attributes
filename[R]
mediainfo[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 8 def initialize(filename) @filename = filename @mediainfo = KodiDedup.config.mediainfo.new(filename: filename) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 13 def <=>(other) if other.resolution != resolution other.resolution <=> resolution elsif other.format_index != format_index other.format_index <=> format_index elsif other.size != size size <=> other.size else 0 end end
==(other)
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 25 def ==(other) width == other.width && height == other.height && format == other.format && size == other.size end
basename()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 55 def basename File.basename(filename) end
format()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 49 def format mediainfo.format rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 'unknown' end
format_index()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 59 def format_index FORMATS.index(format) end
height()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 43 def height mediainfo.height rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 0 end
resolution()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 33 def resolution width * height end
size()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 29 def size (mediainfo.size / (1024*1024.0)).to_i end
to_s()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 63 def to_s "#{basename} (#{format}@#{width}x#{height} #{size}MB)" end
width()
click to toggle source
# File lib/kodi_dedup/media_file.rb, line 37 def width mediainfo.width rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 0 end