lib/tlapse/capture.rb in tlapse-0.4.0 vs lib/tlapse/capture.rb in tlapse-0.4.1
- old
+ new
@@ -1,15 +1,20 @@
require "active_support/core_ext/numeric/time.rb"
module Tlapse
module Capture
- def self.capture_single(format: nil)
- puts "The format key is not yet supported" if format
- `gphoto2 --capture-image-and-download`
+ CAPTURE_FILENAME = "%Y-%m-%d_%H-%M-%S.jpg"
+
+ def self.capture_filename
+ CAPTURE_FILENAME
end
+ def self.capture_single
+ `gphoto2 --capture-image-and-download --filename '#{capture_filename}'`
+ end
+
##
# Calculate how many captures are needed given a duration of capture
# time and a desired interval between captures.
#
# @example
@@ -48,11 +53,11 @@
)
command = "gphoto2 --capture-image-and-download"
command += " -I #{interval}"
command += " -F #{captures}"
- command += ' --filename "%Y-%m-%d_%H-%M-%S.jpg"'
+ command += " --filename '#{capture_filename}'"
end
##
# Capture a timelapse image once per interval while the sun is up.
#
@@ -69,9 +74,9 @@
captures = self.captures_needed(
start_time: sunrise,
end_time: sunset,
interval: interval
)
- "gphoto2 --capture-image-and-download -I #{interval} -F #{captures}"
+ "gphoto2 --capture-image-and-download -I #{interval} -F #{captures} --filename '#{capture_filename}'"
end
end # Capture
end # Tlapse