Class: ExifDatify::DateExtractor
- Inherits:
-
Object
- Object
- ExifDatify::DateExtractor
- Defined in:
- lib/exif_datify.rb
Constant Summary collapse
- DATETIME_FORMAT =
"%Y-%m-%d_%H-%M-%S_"- DATETIME_REGEX =
/^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}/
Instance Attribute Summary collapse
-
#counters ⇒ Object
readonly
Returns the value of attribute counters.
Instance Method Summary collapse
- #extract_datetime(file_path) ⇒ Object
-
#initialize ⇒ DateExtractor
constructor
A new instance of DateExtractor.
- #rename(file_path) ⇒ Object
Constructor Details
#initialize ⇒ DateExtractor
Returns a new instance of DateExtractor.
11 12 13 14 15 |
# File 'lib/exif_datify.rb', line 11 def initialize = ['DateTimeOriginal', 'MediaCreateDate'] @quiet = false @counters = Hash.new(0) end |
Instance Attribute Details
#counters ⇒ Object (readonly)
Returns the value of attribute counters.
7 8 9 |
# File 'lib/exif_datify.rb', line 7 def counters @counters end |
Instance Method Details
#extract_datetime(file_path) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/exif_datify.rb', line 17 def extract_datetime(file_path) = exiftool(file_path) .each do |tag| return DateTime.parse([tag]) if [tag] end nil end |
#rename(file_path) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/exif_datify.rb', line 25 def rename(file_path) @counters[:total] += 1 unless File.basename(file_path) =~ DATETIME_REGEX prepend_date(file_path) end end |