Sha256: fe7c6ca1ffc5fcda654b5537e02e2e14e2152238ffbc146c167a5144eb7d24e6
Contents?: true
Size: 1017 Bytes
Versions: 2
Compression:
Stored size: 1017 Bytes
Contents
module WebVideo class Stream attr_accessor :type, :codec, :details, :resolution # # stream = Stream.new :type => 'Video', :codec => 'mpeg4', :details => 'yuv420p, 640x480 [PAR 1:1 DAR 4:3], 30 tbr, 30 tbn, 30 tbc' # stream.video? # => true # stream.audio? # => false # def initialize(options = {}) options.symbolize_keys! @type = options[:type].to_s.downcase @codec = options[:codec] @details = options[:details] @resolution = extract_resolution_from_details(@details) end def video? @type == 'video' end def audio? @type == 'audio' end def width @resolution ? @resolution[/^\d+/] : nil end def height @resolution ? @resolution[/\d+$/] : nil end private def extract_resolution_from_details(details) return nil if details.blank? result = details[/\s\d+x\d+\s/] result.blank? ? nil : result.strip end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
web_video-1.1.1 | lib/web_video/stream.rb |
web_video-1.1.0 | lib/web_video/stream.rb |