Class: Omnizip::Formats::Rar::Rar5::Models::VolumeOptions
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Omnizip::Formats::Rar::Rar5::Models::VolumeOptions
- 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.
Class Method Summary collapse
-
.parse_size(size_str) ⇒ Integer
Parse human-readable size string.
Instance Method Summary collapse
-
#validate! ⇒ Object
Validate options.
Class Method Details
.parse_size(size_str) ⇒ Integer
Parse human-readable size string
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
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 |