Module: AstroSubframeOrganizer::Utils::ExposureFormat

Included in:
FilenameParsers::FitsHeaderParser, ExifRenamer
Defined in:
lib/astro_subframe_organizer/utils/exposure_format.rb

Overview

Utility module to format exposure times in a human-readable way for path building and filename generation.

Instance Method Summary collapse

Instance Method Details

#format_exposure(exp_time) ⇒ String

Formats an exposure time in seconds into a string with appropriate units (s, ms, or us).

Parameters:

  • exp_time (Numeric)

    The exposure time in seconds

Returns:

  • (String)

    The formatted exposure time with units (e.g., “30.0s”, “500.0ms”, “250.0us”)



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/astro_subframe_organizer/utils/exposure_format.rb', line 10

def format_exposure(exp_time)
  exp_time  = exp_time.to_f
  unit      = 's'
  if exp_time < 1.0
    exp_time *= 1000
    unit = 'ms'
  end
  if exp_time < 1.0
    exp_time *= 1000
    unit = 'us'
  end
  format('%<time>.1f%<unit>s', time: exp_time, unit: unit)
end