Class: YtDlp::OptionsConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/yt_dlp/options_converter.rb

Overview

Class responsible for converting a ruby Hash into valid yt-dlp options. Convert the option Hash into valid yt-dlp options. (key,value) pairs are transformed according to the following rules

  • { key: value } –> ‘–key value’

  • { my_key: value } –> ‘–my-key value’. Allow dev to keep using ruby naming conventions

  • { key: true } –> ‘–key’

  • { key: false } –> ‘–no-key’

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OptionsConverter

Initialize the runner options.

Parameters:

  • options (Hash) (defaults to: {})

    contains the option to pass to yt-dlp



21
22
23
# File 'lib/yt_dlp/options_converter.rb', line 21

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/yt_dlp/options_converter.rb', line 14

def options
  @options
end

Instance Method Details

#to_command_optionsString

Convert the option Hash into valid yt-dlp options. (key,value) pairs are transformed according to the following rules

  • { key: value } –> ‘–key value’

  • { my_key: value } –> ‘–my-key value’. Allow dev to keep using ruby naming conventions

  • { key: true } –> ‘–key’

  • { key: false } –> ‘–no-key’

Returns:

  • (String)

    yt-dlp options



35
36
37
# File 'lib/yt_dlp/options_converter.rb', line 35

def to_command_options
  @to_command_options ||= build_to_command_options
end