Class: Omnizip::Profile::CompressionProfile Abstract
- Inherits:
-
Object
- Object
- Omnizip::Profile::CompressionProfile
- Defined in:
- lib/omnizip/profile/compression_profile.rb
Overview
Subclass and override #suitable_for? to implement a custom profile
Base class for compression profiles
A compression profile encapsulates a set of compression settings that define how files should be compressed. This includes the algorithm, compression level, filters, and other options.
Direct Known Subclasses
ArchiveProfile, BalancedProfile, BinaryProfile, CustomProfile, FastProfile, MaximumProfile, TextProfile
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#solid ⇒ Object
readonly
Returns the value of attribute solid.
Instance Method Summary collapse
-
#apply_to(options) ⇒ Hash
Apply this profile to compression options.
-
#initialize(name:, algorithm:, level:, filter: nil, solid: false, description: "") ⇒ CompressionProfile
constructor
Initialize a new compression profile.
-
#inspect ⇒ String
Inspect representation.
-
#suitable_for?(_mime_type) ⇒ Boolean
Check if this profile is suitable for a given MIME type.
-
#to_h ⇒ Hash
Get profile information as a hash.
-
#to_s ⇒ String
String representation of the profile.
Constructor Details
#initialize(name:, algorithm:, level:, filter: nil, solid: false, description: "") ⇒ CompressionProfile
Initialize a new compression profile
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omnizip/profile/compression_profile.rb', line 25 def initialize( name:, algorithm:, level:, filter: nil, solid: false, description: "" ) @name = name @algorithm = algorithm @level = level @filter = filter @solid = solid @description = description validate! freeze end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def algorithm @algorithm end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def description @description end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def filter @filter end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def name @name end |
#solid ⇒ Object (readonly)
Returns the value of attribute solid.
14 15 16 |
# File 'lib/omnizip/profile/compression_profile.rb', line 14 def solid @solid end |
Instance Method Details
#apply_to(options) ⇒ Hash
Apply this profile to compression options
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omnizip/profile/compression_profile.rb', line 48 def apply_to() = .dup [:algorithm] = algorithm [:level] = level [:filter] = resolve_filter([:file_type]) if filter [:solid] = solid end |
#inspect ⇒ String
Inspect representation
92 93 94 95 |
# File 'lib/omnizip/profile/compression_profile.rb', line 92 def inspect "#<#{self.class.name} name=#{name} " \ "algorithm=#{algorithm} level=#{level}>" end |
#suitable_for?(_mime_type) ⇒ Boolean
Check if this profile is suitable for a given MIME type
63 64 65 66 |
# File 'lib/omnizip/profile/compression_profile.rb', line 63 def suitable_for?(_mime_type) # Default implementation - subclasses should override true end |
#to_h ⇒ Hash
Get profile information as a hash
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/omnizip/profile/compression_profile.rb', line 71 def to_h { name: name, algorithm: algorithm, level: level, filter: filter, solid: solid, description: description, } end |
#to_s ⇒ String
String representation of the profile
85 86 87 |
# File 'lib/omnizip/profile/compression_profile.rb', line 85 def to_s "#{name} - #{description}" end |