Class: MediaInfo::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/media_info/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Parser

Returns a new instance of Parser.

Raises:

  • (StandardError)


13
14
15
16
17
18
# File 'lib/media_info/parser.rb', line 13

def initialize(file_path)
  @file_path = file_path

  # check for MediaInfo CLI
  raise StandardError, 'mediainfo command-line interface not installed' unless cli_available?
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



11
12
13
# File 'lib/media_info/parser.rb', line 11

def file_path
  @file_path
end

Class Method Details

.call(file_path) ⇒ Object



7
8
9
# File 'lib/media_info/parser.rb', line 7

def self.call(file_path)
  new(file_path).parse
end

Instance Method Details

#parseObject



20
21
22
23
24
25
26
# File 'lib/media_info/parser.rb', line 20

def parse
  raw_xml_response = execute_command

  raise "Execution of `#{command}` failed: #{raw_xml_response.inspect}" unless $CHILD_STATUS.success?

  create_streams(raw_xml_response)
end