Sha256: 9fe2693e83d6b408256876be41444b605ca9fbec3ad6f0264e02b3a5a2625ae8

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

module Ffprober
  class Parser
    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

    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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffprober-0.5.5 lib/ffprober/parser.rb
ffprober-0.5.3 lib/ffprober/parser.rb
ffprober-0.5.2 lib/ffprober/parser.rb