Class: Bulldog::Attachment::Video
- Includes:
- HasDimensions
- Defined in:
- lib/bulldog/attachment/video.rb
Defined Under Namespace
Classes: AudioTrack, Track, VideoTrack
Instance Attribute Summary
Attributes inherited from Maybe
#name, #record, #saved, #stream, #value
Instance Method Summary collapse
-
#audio_tracks(style_name = nil) ⇒ Object
Return the video tracks of the named style, as an array of AudioTrack objects.
-
#duration(style_name) ⇒ Object
Return the duration of the named style, as an ActiveSupport::Duration.
- #unload ⇒ Object
-
#video_tracks(style_name = nil) ⇒ Object
Return the video tracks of the named style, as an array of VideoTrack objects.
Methods included from HasDimensions
#aspect_ratio, #dimensions, #height, included, #width
Methods inherited from Base
#content_type, #destroy, #examine, #file_name, #file_size, #initialize, #path, #process, #process!, #save, try, #url
Methods inherited from Maybe
#==, #copy_for, handle, #initialize, #interpolate_path, #interpolate_url, #load, #read_storable_attributes, #reflection, #reload, #saved?, #type
Constructor Details
This class inherits a constructor from Bulldog::Attachment::Base
Instance Method Details
#audio_tracks(style_name = nil) ⇒ Object
Return the video tracks of the named style, as an array of AudioTrack objects.
AudioTrack objects do not yet have any useful methods.
48 49 50 51 |
# File 'lib/bulldog/attachment/video.rb', line 48 def audio_tracks(style_name=nil) examine @original_audio_tracks end |
#duration(style_name) ⇒ Object
Return the duration of the named style, as an ActiveSupport::Duration.
This runs ffmpeg for, and only for, the original style.
style_name
defaults to the attribute’s #default_style.
15 16 17 |
# File 'lib/bulldog/attachment/video.rb', line 15 def duration(style_name) from_examination :@original_duration end |
#unload ⇒ Object
55 56 57 58 59 60 |
# File 'lib/bulldog/attachment/video.rb', line 55 def unload super instance_variables.grep(/@original_/).each do |name| instance_variable_set(name, nil) end end |
#video_tracks(style_name = nil) ⇒ Object
Return the video tracks of the named style, as an array of VideoTrack objects.
Each VideoTrack has:
* <tt>#duration</tt> - the duration of the video track.
* <tt>#dimensions</tt> - the [width, height] of the video
track.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bulldog/attachment/video.rb', line 29 def video_tracks(style_name=nil) style_name ||= reflection.default_style if style_name.equal?(:original) from_examination :@original_video_tracks else style = reflection.styles[style_name] video_tracks(:original).map do |video_track| dimensions = resize_dimensions(dimensions(:original), style) VideoTrack.new(:dimensions => dimensions) end end end |