Class: Omnizip::Formats::Rar::Rar5::Models::VolumeOptions

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/omnizip/formats/rar/rar5/models/volume_options.rb

Overview

Volume options for multi-volume archives

This model configures split archive behavior, including maximum volume size and naming convention.

Examples:

Create with default options

options = VolumeOptions.new
options.max_volume_size # => 104857600 (100 MB)

Create with custom size

options = VolumeOptions.new(max_volume_size: 10 * 1024 * 1024)
options.max_volume_size # => 10485760 (10 MB)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_size(size_str) ⇒ Integer

Parse human-readable size string

Parameters:

  • size_str (String)

    Size with suffix (e.g., "10M", "1G")

Returns:

  • (Integer)

    Size in bytes



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/omnizip/formats/rar/rar5/models/volume_options.rb', line 47

def self.parse_size(size_str)
  return size_str if size_str.is_a?(Integer)

  match = size_str.match(/^(\d+(?:\.\d+)?)\s*([KMGT])?$/i)
  unless match
    raise ArgumentError,
          "Invalid size format: #{size_str}"
  end

  value = match[1].to_f
  suffix = match[2]&.upcase

  multiplier = case suffix
               when "K" then 1024
               when "M" then 1024**2
               when "G" then 1024**3
               when "T" then 1024**4
               else 1
               end

  (value * multiplier).to_i
end

Instance Method Details

#validate!Object

Validate options

Raises:

  • (ArgumentError)

    if max_volume_size is too small



37
38
39
40
41
# File 'lib/omnizip/formats/rar/rar5/models/volume_options.rb', line 37

def validate!
  if max_volume_size < 65_536 # 64 KB minimum
    raise ArgumentError, "Volume size must be at least 64 KB"
  end
end