Class: ExtractTtc::Configuration
- Inherits:
-
Object
- Object
- ExtractTtc::Configuration
- Defined in:
- lib/extract_ttc/configuration.rb
Overview
Configuration class for runtime settings
This plain Ruby class encapsulates all runtime configuration options for the extract_ttc gem. It provides sensible defaults and supports merging with user-provided options.
The configuration is immutable by design - the merge method returns a new Configuration instance rather than modifying the existing one.
Instance Attribute Summary collapse
-
#output_directory ⇒ String
Directory path where extracted fonts will be written.
-
#overwrite_existing ⇒ Boolean
Whether to overwrite existing files during extraction.
-
#validate_checksums ⇒ Boolean
Whether to validate font table checksums.
-
#verbose ⇒ Boolean
Whether to enable verbose output during operations.
Class Method Summary collapse
-
.default ⇒ Configuration
Create a configuration instance with default values.
Instance Method Summary collapse
-
#initialize(output_directory: ".", overwrite_existing: false, validate_checksums: true, verbose: false) ⇒ Configuration
constructor
Initialize a new configuration instance.
-
#merge(options) ⇒ Configuration
Merge this configuration with new options.
-
#to_h ⇒ Hash
Convert configuration to hash representation.
Constructor Details
#initialize(output_directory: ".", overwrite_existing: false, validate_checksums: true, verbose: false) ⇒ Configuration
Initialize a new configuration instance
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/extract_ttc/configuration.rb', line 43 def initialize( output_directory: ".", overwrite_existing: false, validate_checksums: true, verbose: false ) @output_directory = output_directory @overwrite_existing = overwrite_existing @validate_checksums = validate_checksums @verbose = verbose end |
Instance Attribute Details
#output_directory ⇒ String
Returns Directory path where extracted fonts will be written.
26 27 28 |
# File 'lib/extract_ttc/configuration.rb', line 26 def output_directory @output_directory end |
#overwrite_existing ⇒ Boolean
Returns Whether to overwrite existing files during extraction.
29 30 31 |
# File 'lib/extract_ttc/configuration.rb', line 29 def overwrite_existing @overwrite_existing end |
#validate_checksums ⇒ Boolean
Returns Whether to validate font table checksums.
32 33 34 |
# File 'lib/extract_ttc/configuration.rb', line 32 def validate_checksums @validate_checksums end |
#verbose ⇒ Boolean
Returns Whether to enable verbose output during operations.
35 36 37 |
# File 'lib/extract_ttc/configuration.rb', line 35 def verbose @verbose end |
Class Method Details
.default ⇒ Configuration
Create a configuration instance with default values
This is a convenience factory method that returns a new Configuration with all default settings applied.
66 67 68 |
# File 'lib/extract_ttc/configuration.rb', line 66 def self.default new end |
Instance Method Details
#merge(options) ⇒ Configuration
Merge this configuration with new options
Creates a new Configuration instance with values merged from the provided options hash. The original configuration is not modified, ensuring immutability.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/extract_ttc/configuration.rb', line 89 def merge() self.class.new( output_directory: .fetch(:output_directory, @output_directory), overwrite_existing: .fetch(:overwrite_existing, @overwrite_existing), validate_checksums: .fetch(:validate_checksums, @validate_checksums), verbose: .fetch(:verbose, @verbose), ) end |
#to_h ⇒ Hash
Convert configuration to hash representation
Returns a hash containing all configuration settings with their current values. This is useful for serialization, debugging, or passing the configuration to other components.
117 118 119 120 121 122 123 124 |
# File 'lib/extract_ttc/configuration.rb', line 117 def to_h { output_directory: @output_directory, overwrite_existing: @overwrite_existing, validate_checksums: @validate_checksums, verbose: @verbose, } end |