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
18
# 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]
  
  extract_resolution_from_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

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#audio?Boolean

Returns:

  • (Boolean)


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

def audio?
  @type == 'audio'
end

#resolutionObject



28
29
30
31
32
# File 'lib/web_video/stream.rb', line 28

def resolution
  if width && height
    "#{width}x#{height}"
  end
end

#video?Boolean

Returns:

  • (Boolean)


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

def video?
  @type == 'video'
end