Class: Ehbrs::Videos::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs/videos/track.rb

Constant Summary collapse

FFPROBE_PATTERN =
/\A\s*Stream\s\#(\d+:\d+)(?:\(([^\)]+)\))?:\s*([^:]+):\s*([a-z0-9]+)(.*)/
.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_string(string) ⇒ Object



11
12
13
14
15
16
# File 'lib/ehbrs/videos/track.rb', line 11

def create_from_string(string)
  m = FFPROBE_PATTERN.match(string)
  return nil unless m

  new(m[1].to_i, m[3], m[2], m[4], m[5].strip)
end

Instance Method Details

#to_sObject



21
22
23
24
# File 'lib/ehbrs/videos/track.rb', line 21

def to_s
  "[#{type}(#{number}): #{codec}/#{language || '-'}" +
    extra.if_present('') { |v| " | #{v}" } + ']'
end