Class: Media
- Inherits:
-
Object
- Object
- Media
- Defined in:
- lib/gst-kitchen/media.rb
Defined Under Namespace
Classes: Format
Class Method Summary collapse
Instance Method Summary collapse
- #aquire_meta_data! ⇒ Object
- #duration ⇒ Object
- #file_size ⇒ Object
-
#initialize(file) ⇒ Media
constructor
A new instance of Media.
- #length ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(file) ⇒ Media
Returns a new instance of Media.
18 19 20 21 |
# File 'lib/gst-kitchen/media.rb', line 18 def initialize(file) @file = file @md5_digest = Digest::MD5.file(@file).hexdigest.force_encoding("UTF-8") end |
Class Method Details
Instance Method Details
#aquire_meta_data! ⇒ Object
45 46 47 |
# File 'lib/gst-kitchen/media.rb', line 45 def [:duration, :file_size].each { |m| send(m) } end |
#duration ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/gst-kitchen/media.rb', line 35 def duration return @duration if @duration hours = length / (60 * 60) minutes = (length - hours * 60 * 60) / 60 seconds = length % 60 @duration = "#{"%02i" % hours}:#{"%02i" % minutes}:#{"%02i" % seconds}" end |
#file_size ⇒ Object
31 32 33 |
# File 'lib/gst-kitchen/media.rb', line 31 def file_size @file_size ||= File.size(@file) end |
#length ⇒ Object
23 24 25 |
# File 'lib/gst-kitchen/media.rb', line 23 def length media_info["length"].to_i end |
#title ⇒ Object
27 28 29 |
# File 'lib/gst-kitchen/media.rb', line 27 def title media_info["title"] end |