Class: Media::Container
- Inherits:
-
Object
- Object
- Media::Container
- Defined in:
- lib/media/container.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #format ⇒ Object
- #frames ⇒ Object
-
#initialize(args, &block) ⇒ Container
constructor
A new instance of Container.
- #metadata ⇒ Object
- #options(value = nil) ⇒ Object (also: #options=)
- #streams(type = /.*/) ⇒ Object
Constructor Details
#initialize(args, &block) ⇒ Container
Returns a new instance of Container.
12 13 14 15 16 17 18 |
# File 'lib/media/container.rb', line 12 def initialize(args, &block) @url = args.fetch(:url) { raise ':url required'} @probe = args.fetch(:probe, Command::Probe) @options = args.fetch(:options, []) block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/media/container.rb', line 10 def url @url end |
Instance Method Details
#format ⇒ Object
27 28 29 |
# File 'lib/media/container.rb', line 27 def format OpenStruct.new(['format']) end |
#frames ⇒ Object
36 37 38 39 40 |
# File 'lib/media/container.rb', line 36 def frames warn 'show_frames option required' unless ['frames'] Array(['frames']).map {|s| OpenStruct.new(s)} end |
#metadata ⇒ Object
42 43 44 |
# File 'lib/media/container.rb', line 42 def @metadata ||= JSON.parse(probe.out) end |
#options(value = nil) ⇒ Object Also known as: options=
20 21 22 23 24 |
# File 'lib/media/container.rb', line 20 def (value=nil) return @options + unless value @options = value.map {|k,v| Option.new(key: k, value: v)} end |
#streams(type = /.*/) ⇒ Object
31 32 33 34 |
# File 'lib/media/container.rb', line 31 def streams(type=/.*/) ['streams'].select {|s| s['codec_type'].match(type)}. map {|s| OpenStruct.new(s)} end |