Class: Ffprober::Parsers::UrlParser

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

Constant Summary collapse

VALID_URI_REGEX =
/\A#{URI::DEFAULT_PARSER.make_regexp}\z/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(url_to_parse, exec = Ffprober::Ffmpeg::Exec.new) ⇒ UrlParser

Returns a new instance of UrlParser.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
# File 'lib/ffprober/parsers/url.rb', line 11

def initialize(url_to_parse, exec = Ffprober::Ffmpeg::Exec.new)
  raise ArgumentError, "#{url_to_parse} is not a valid URL" unless valid_url?(url_to_parse)

  @url_to_parse = url_to_parse
  @exec = exec
end

Instance Method Details

#loadObject



18
19
20
# File 'lib/ffprober/parsers/url.rb', line 18

def load
  JsonParser.new(@exec.json_output(@url_to_parse))
end