Class: Vidload::Custom::Api::DownloaderBuilder

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

Constant Summary collapse

REQUIRED_ARGS =
%i[service_url video_url playwright_cli_path].freeze

Instance Method Summary collapse

Constructor Details

#initializeDownloaderBuilder

Returns a new instance of DownloaderBuilder.



14
15
16
# File 'lib/vidload/custom/api.rb', line 14

def initialize
  @kwargs = {}
end

Instance Method Details

#buildObject



53
54
55
56
57
58
59
# File 'lib/vidload/custom/api.rb', line 53

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

  Downloader.new(**@kwargs)
end

#is_headless?(headless) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/vidload/custom/api.rb', line 48

def is_headless?(headless)
  @kwargs[:headless] = headless
  self
end

#with_author_name(author_name) ⇒ Object



38
39
40
41
# File 'lib/vidload/custom/api.rb', line 38

def with_author_name(author_name)
  @kwargs[:author_name] = author_name
  self
end

#with_kwargs(**kwargs) ⇒ Object



18
19
20
21
# File 'lib/vidload/custom/api.rb', line 18

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

#with_playwright_cli_path(playwright_cli_path) ⇒ Object



43
44
45
46
# File 'lib/vidload/custom/api.rb', line 43

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

#with_service_url(service_url) ⇒ Object



23
24
25
26
# File 'lib/vidload/custom/api.rb', line 23

def with_service_url(service_url)
  @kwargs[:service_url] = service_url
  self
end

#with_title(title) ⇒ Object



33
34
35
36
# File 'lib/vidload/custom/api.rb', line 33

def with_title(title)
  @kwargs[:title] = title
  self
end

#with_video_url(video_url) ⇒ Object



28
29
30
31
# File 'lib/vidload/custom/api.rb', line 28

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