Class: RAR::CommandLineOptions

Inherits:
Hash
  • Object
show all
Defined in:
library/rar/command_line_options.rb

Overview

CommandLineOptions is a convenience class to making adding new command-line switches trivial.

Constant Summary collapse

OptionsMap =

The mappings that convert an option to an actual command line switch.

{
  extra:        ->(extra) { extra },
  force:        ->(force) { '-y' if force },
  old_format:   ->(old_format) { '-vn' if old_format },
  volume_size:  ->(volume_size) { "-v#{volume_size}" },
  compression:  ->(compression = 0) { "-m#{compression}" },
  exclude_path: ->(exclude_path) { '-ep' },
  password:     ->(password) { "-p#{password}" },
}

Instance Method Summary collapse

Instance Method Details

#to_aArray

Returns the list of command line options.

Returns:

  • (Array)

    the list of command line options.



19
20
21
22
23
24
25
# File 'library/rar/command_line_options.rb', line 19

def to_a
  map do |key, value|
    if block = OptionsMap[key]
      block.call value
    end
  end.compact
end