Class: Ffprober::Parser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ffprober/parser.rb

Class Method Summary collapse

Class Method Details

.check_versionObject

Raises:



35
36
37
38
# File 'lib/ffprober/parser.rb', line 35

def self.check_version
  msg = "found version: #{FfprobeVersion.version}"
  raise UnsupportedVersion, msg if FfprobeVersion.invalid?
end

.from_file(file_to_parse) ⇒ Object

Raises:



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

def self.from_file(file_to_parse)
  check_version

  raise EmptyInput, file_to_parse if File.zero?(file_to_parse)

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

.from_json(json_to_parse) ⇒ Object



29
30
31
32
# File 'lib/ffprober/parser.rb', line 29

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

.from_url(url_to_parse) ⇒ Object



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

def self.from_url(url_to_parse)
  check_version

  url_parser = Parsers::UrlParser.new(url_to_parse)
  json_parser = url_parser.load
  Ffprober::Wrapper.new(json_parser.json)
end