Class: Omnizip::Profile::TextProfile

Inherits:
CompressionProfile show all
Defined in:
lib/omnizip/profile/text_profile.rb

Overview

Text compression profile

Optimized for compressing text files. Uses PPMd7 which excels at text compression through context modeling.

Instance Attribute Summary

Attributes inherited from CompressionProfile

#algorithm, #description, #filter, #level, #name, #solid

Instance Method Summary collapse

Methods inherited from CompressionProfile

#apply_to, #inspect, #to_h, #to_s

Constructor Details

#initializeTextProfile

Initialize text profile



11
12
13
14
15
16
17
18
19
20
# File 'lib/omnizip/profile/text_profile.rb', line 11

def initialize
  super(
    name: :text,
    algorithm: :ppmd7,
    level: 6,
    filter: nil,
    solid: false,
    description: "Optimized for text files"
  )
end

Instance Method Details

#suitable_for?(mime_type) ⇒ Boolean

Check if this profile is suitable for a MIME type

Parameters:

  • mime_type (String)

    MIME type string

Returns:

  • (Boolean)

    true if MIME type is text-based



26
27
28
29
30
# File 'lib/omnizip/profile/text_profile.rb', line 26

def suitable_for?(mime_type)
  return true unless mime_type

  FileType::MimeClassifier.text?(mime_type)
end