Class: Vidload::Mp4::Api::DownloaderBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/vidload/mp4/api.rb

Constant Summary collapse

REQUIRED_ARGS =
%i[video_url video_hub_url playwright_cli_path].freeze

Instance Method Summary collapse

Constructor Details

#initializeDownloaderBuilder

Returns a new instance of DownloaderBuilder.



16
17
18
# File 'lib/vidload/mp4/api.rb', line 16

def initialize
  @kwargs = {}
end

Instance Method Details

#buildObject



45
46
47
48
49
50
51
52
53
# File 'lib/vidload/mp4/api.rb', line 45

def build
  REQUIRED_ARGS.each do |required_arg|
    raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
  end

  @kwargs[:video_name] = @kwargs[:video_url].split('/').last unless @kwargs[:video_name]

  Downloader.new(**@kwargs)
end

#with_kwargs(**kwargs) ⇒ Object



20
21
22
23
# File 'lib/vidload/mp4/api.rb', line 20

def with_kwargs(**kwargs)
  @kwargs = kwargs
  self
end

#with_playwright_cli_path(playwright_cli_path) ⇒ Object



40
41
42
43
# File 'lib/vidload/mp4/api.rb', line 40

def with_playwright_cli_path(playwright_cli_path)
  @kwargs[:playwright_cli_path] = playwright_cli_path
  self
end

#with_video_hub_url(video_hub_url) ⇒ Object



35
36
37
38
# File 'lib/vidload/mp4/api.rb', line 35

def with_video_hub_url(video_hub_url)
  @kwargs[:video_hub_url] = video_hub_url
  self
end

#with_video_name(video_name) ⇒ Object



25
26
27
28
# File 'lib/vidload/mp4/api.rb', line 25

def with_video_name(video_name)
  @kwargs[:video_name] = video_name
  self
end

#with_video_url(video_url) ⇒ Object



30
31
32
33
# File 'lib/vidload/mp4/api.rb', line 30

def with_video_url(video_url)
  @kwargs[:video_url] = video_url
  self
end