Class: Frames::FrameConstructor
- Inherits:
-
Object
- Object
- Frames::FrameConstructor
- Defined in:
- lib/frames/frame_constructor.rb
Instance Method Summary collapse
-
#frame_hashes ⇒ Object
Internal: Converts each raw frame into Hash.
-
#frames ⇒ Object
Internal: Maps Array of hashes from output into Array Frame objects.
-
#initialize(ffprobe_output) ⇒ FrameConstructor
constructor
A new instance of FrameConstructor.
-
#split_raw_frames ⇒ Object
Internal: Splits ffprobe output into seperate frames.
Constructor Details
#initialize(ffprobe_output) ⇒ FrameConstructor
Returns a new instance of FrameConstructor.
9 10 11 |
# File 'lib/frames/frame_constructor.rb', line 9 def initialize(ffprobe_output) @raw_output = ffprobe_output end |
Instance Method Details
#frame_hashes ⇒ Object
Internal: Converts each raw frame into Hash.
Returns Array of Hashes.
21 22 23 24 25 26 27 28 29 |
# File 'lib/frames/frame_constructor.rb', line 21 def frame_hashes hashes = [] split_raw_frames.each do |frame| hashes << raw_frame_to_hash(frame) end hashes end |
#frames ⇒ Object
Internal: Maps Array of hashes from output into Array Frame objects.
14 15 16 |
# File 'lib/frames/frame_constructor.rb', line 14 def frames frame_hashes.map { |h| Frame.new(h) } end |
#split_raw_frames ⇒ Object
Internal: Splits ffprobe output into seperate frames.
Returns Array of raw ffprobe frames.
34 35 36 37 38 |
# File 'lib/frames/frame_constructor.rb', line 34 def split_raw_frames @raw_output.split('[/FRAME]').take_while { |f| f['[FRAME'] } end |