Class: FFProbe::Parser
- Inherits:
-
Object
- Object
- FFProbe::Parser
- Defined in:
- lib/ffprobe/parser.rb
Instance Method Summary collapse
Instance Method Details
#parse_stream(io) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ffprobe/parser.rb', line 4 def parse_stream(io) result = {} dest = nil io.each_line do |line| # $stderr.puts line line.chomp! case line when /\A\[(\w+)\]\Z/ (result[$1.to_sym] ||= []).push( dest = {} ) when /\A\[\/(\w+)\]\Z/ # ignored, stanzas can't nest. when /\A(\w+)=(.*)/ if dest dest[$1.to_sym] = $2 == "N/A" ? nil : $2.strip end else (result[:EXTRA] ||= []).push(line) end end result end |