Class: KodiDedup::MediaFile
- Inherits:
-
Object
- Object
- KodiDedup::MediaFile
- Includes:
- Comparable
- Defined in:
- lib/kodi_dedup/media_file.rb
Constant Summary collapse
- FORMATS =
['unknown', 'MPEG-4 Visual', 'AVC', 'HEVC']
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#mediainfo ⇒ Object
readonly
Returns the value of attribute mediainfo.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #basename ⇒ Object
- #format ⇒ Object
- #format_index ⇒ Object
- #height ⇒ Object
-
#initialize(filename) ⇒ MediaFile
constructor
A new instance of MediaFile.
- #resolution ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/kodi_dedup/media_file.rb', line 4 def filename @filename end |
#mediainfo ⇒ Object (readonly)
Returns the value of attribute mediainfo.
4 5 6 |
# File 'lib/kodi_dedup/media_file.rb', line 4 def mediainfo @mediainfo end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
25 26 27 |
# 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 ⇒ Object
55 56 57 |
# File 'lib/kodi_dedup/media_file.rb', line 55 def basename File.basename(filename) end |
#format ⇒ Object
49 50 51 52 53 |
# File 'lib/kodi_dedup/media_file.rb', line 49 def format mediainfo.format rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 'unknown' end |
#format_index ⇒ Object
59 60 61 |
# File 'lib/kodi_dedup/media_file.rb', line 59 def format_index FORMATS.index(format) end |
#height ⇒ Object
43 44 45 46 47 |
# File 'lib/kodi_dedup/media_file.rb', line 43 def height mediainfo.height rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 0 end |
#resolution ⇒ Object
33 34 35 |
# File 'lib/kodi_dedup/media_file.rb', line 33 def resolution width * height end |
#size ⇒ Object
29 30 31 |
# File 'lib/kodi_dedup/media_file.rb', line 29 def size (mediainfo.size / (1024*1024.0)).to_i end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/kodi_dedup/media_file.rb', line 63 def to_s "#{basename} (#{format}@#{width}x#{height} #{size}MB)" end |
#width ⇒ Object
37 38 39 40 41 |
# File 'lib/kodi_dedup/media_file.rb', line 37 def width mediainfo.width rescue ::Mediainfo::StreamProxy::NoStreamsForProxyError 0 end |