Class: AstroSubframeOrganizer::PathBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/astro_subframe_organizer/path_builder.rb

Overview

Factory for creating and using path builders.

This class serves as the entry point for building folder paths for astrophotography image files. It uses the Strategy pattern to delegate path construction to specialized builder classes based on the image file type (Dark, Flat, Light, or Bias).

The resulting folder paths contain keywords that facilitate automatic file matching in PixInsight’s WeightedBatchPreProcessing (WBPP) script during calibration and integration.

Usage:

path = PathBuilder.build_for()        # => "Dark_ISO_100_EXP_30.0s_..."
full_path = PathBuilder.target_path_for()   # => "Dark_ISO_100_.../filename.fit"

See the individual builder classes for details on keyword structure for each file type:

  • DarkPathBuilder for dark calibration frames

  • FlatPathBuilder for flat field frames

  • LightPathBuilder for science (light) frames

  • BiasPathBuilder for bias (zero-exposure) frames

See README.md for details on the WBPP calibration workflow and keyword matching.

Class Method Summary collapse

Class Method Details

.build_for(metadata) ⇒ String

Builds the folder path for an image based on its type and metadata.

Parameters:

  • metadata (Object)

    Image metadata object (typically an Astrophoto instance) Must respond to: type, dark_flat?, file_format

Returns:

  • (String)

    The folder path with WBPP-compatible keywords

Raises:

  • (ArgumentError)

    If the image type is not supported



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/astro_subframe_organizer/path_builder.rb', line 31

def self.build_for()
  builder = case .type
            when 'Dark'
              PathBuilders::DarkPathBuilder.new()
            when 'Flat'
              PathBuilders::FlatPathBuilder.new()
            when 'Light'
              PathBuilders::LightPathBuilder.new()
            when 'Bias'
              PathBuilders::BiasPathBuilder.new()
            else
              raise ArgumentError, "Unsupported type: #{.type}"
            end
  builder.build
end

.target_path_for(metadata) ⇒ String

Builds the full target path (folder + filename) for an image.

Parameters:

  • metadata (Object)

    Image metadata object with filename and type

Returns:

  • (String)

    The full path where the file will be moved



51
52
53
# File 'lib/astro_subframe_organizer/path_builder.rb', line 51

def self.target_path_for()
  File.join(build_for(), .filename)
end