Class: Ffprober::Parser

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

Class Method Summary collapse

Class Method Details

.from_file(file_to_parse) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ffprober/parser.rb', line 5

def self.from_file(file_to_parse)
  if FfprobeVersion.invalid?
    fail UnsupportedVersion, "found version: #{FfprobeVersion.version}"
  end

  if File.zero?(file_to_parse)
    fail EmptyInput, file_to_parse
  end

  file_parser = Ffprober::Parsers::File.new(file_to_parse)
  json_parser = file_parser.load
  Ffprober::Wrapper.new(json_parser.json)
end

.from_json(json_to_parse) ⇒ Object



19
20
21
22
# File 'lib/ffprober/parser.rb', line 19

def self.from_json(json_to_parse)
  json_parser = Ffprober::Parsers::Json.new(json_to_parse)
  Ffprober::Wrapper.new(json_parser.json)
end