Class: Omnizip::Models::ConversionOptions
- Inherits:
-
Object
- Object
- Omnizip::Models::ConversionOptions
- Defined in:
- lib/omnizip/models/conversion_options.rb
Overview
Options for converting between archive formats.
Plain Ruby value object. (Track 13 of TODO.refactor recommends migrating this to lutaml-model once symbol-typed attributes are available.)
Constant Summary collapse
- VALID_FORMATS =
%i[zip seven_zip 7z].freeze
Instance Attribute Summary collapse
-
#compression ⇒ Object
Returns the value of attribute compression.
-
#compression_level ⇒ Object
Returns the value of attribute compression_level.
-
#delete_source ⇒ Object
Returns the value of attribute delete_source.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#preserve_metadata ⇒ Object
Returns the value of attribute preserve_metadata.
-
#solid ⇒ Object
Returns the value of attribute solid.
-
#source_format ⇒ Object
Returns the value of attribute source_format.
-
#target_format ⇒ Object
Returns the value of attribute target_format.
-
#temp_directory ⇒ Object
Returns the value of attribute temp_directory.
Instance Method Summary collapse
-
#initialize(source_format: nil, target_format: :seven_zip, compression: nil, compression_level: 5, filter: nil, preserve_metadata: true, temp_directory: nil, solid: true, delete_source: false) ⇒ ConversionOptions
constructor
A new instance of ConversionOptions.
- #to_h ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(source_format: nil, target_format: :seven_zip, compression: nil, compression_level: 5, filter: nil, preserve_metadata: true, temp_directory: nil, solid: true, delete_source: false) ⇒ ConversionOptions
Returns a new instance of ConversionOptions.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/omnizip/models/conversion_options.rb', line 17 def initialize( source_format: nil, target_format: :seven_zip, compression: nil, compression_level: 5, filter: nil, preserve_metadata: true, temp_directory: nil, solid: true, delete_source: false ) @source_format = source_format @target_format = target_format @compression = compression @compression_level = compression_level @filter = filter @preserve_metadata = @temp_directory = temp_directory @solid = solid @delete_source = delete_source end |
Instance Attribute Details
#compression ⇒ Object
Returns the value of attribute compression.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def compression @compression end |
#compression_level ⇒ Object
Returns the value of attribute compression_level.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def compression_level @compression_level end |
#delete_source ⇒ Object
Returns the value of attribute delete_source.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def delete_source @delete_source end |
#filter ⇒ Object
Returns the value of attribute filter.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def filter @filter end |
#preserve_metadata ⇒ Object
Returns the value of attribute preserve_metadata.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def @preserve_metadata end |
#solid ⇒ Object
Returns the value of attribute solid.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def solid @solid end |
#source_format ⇒ Object
Returns the value of attribute source_format.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def source_format @source_format end |
#target_format ⇒ Object
Returns the value of attribute target_format.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def target_format @target_format end |
#temp_directory ⇒ Object
Returns the value of attribute temp_directory.
13 14 15 |
# File 'lib/omnizip/models/conversion_options.rb', line 13 def temp_directory @temp_directory end |
Instance Method Details
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/omnizip/models/conversion_options.rb', line 39 def to_h { source_format: source_format, target_format: target_format, compression: compression, compression_level: compression_level, filter: filter, preserve_metadata: , temp_directory: temp_directory, solid: solid, delete_source: delete_source, } end |
#validate ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/omnizip/models/conversion_options.rb', line 53 def validate validate_format(target_format, "target") validate_format(source_format, "source") if source_format validate_compression_level true end |