Class: WebVideo::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/web_video/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Stream

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



10
11
12
13
14
15
16
17
# File 'lib/web_video/stream.rb', line 10

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

Instance Attribute Details

#codecObject

Returns the value of attribute codec.



3
4
5
# File 'lib/web_video/stream.rb', line 3

def codec
  @codec
end

#detailsObject

Returns the value of attribute details.



3
4
5
# File 'lib/web_video/stream.rb', line 3

def details
  @details
end

#resolutionObject

Returns the value of attribute resolution.



3
4
5
# File 'lib/web_video/stream.rb', line 3

def resolution
  @resolution
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/web_video/stream.rb', line 3

def type
  @type
end

Instance Method Details

#audio?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/web_video/stream.rb', line 23

def audio?
  @type == 'audio'
end

#heightObject



31
32
33
# File 'lib/web_video/stream.rb', line 31

def height
  @resolution ? @resolution[/\d+$/] : nil
end

#video?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/web_video/stream.rb', line 19

def video?
  @type == 'video'
end

#widthObject



27
28
29
# File 'lib/web_video/stream.rb', line 27

def width
  @resolution ? @resolution[/^\d+/] : nil
end