Class: ExifDatify::DateExtractor
- Inherits:
-
Object
- Object
- ExifDatify::DateExtractor
- Defined in:
- lib/exif_datify.rb
Constant Summary collapse
- 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.
-
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #extract_datetime(file_path) ⇒ Object
-
#initialize ⇒ DateExtractor
constructor
A new instance of DateExtractor.
- #quiet! ⇒ Object
- #rename(file_path) ⇒ Object
Constructor Details
#initialize ⇒ DateExtractor
Returns a new instance of DateExtractor.
11 12 13 14 15 16 |
# File 'lib/exif_datify.rb', line 11 def initialize = ['DateTimeOriginal', 'MediaCreateDate'] @datetime_format = "%Y-%m-%d_%H-%M-%S_" @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 |
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
8 9 10 |
# File 'lib/exif_datify.rb', line 8 def datetime_format @datetime_format end |
#tags ⇒ Object
Returns the value of attribute tags.
8 9 10 |
# File 'lib/exif_datify.rb', line 8 def end |
Instance Method Details
#extract_datetime(file_path) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/exif_datify.rb', line 22 def extract_datetime(file_path) = exiftool(file_path) .each do |tag| return DateTime.parse([tag]) if [tag] end nil end |
#quiet! ⇒ Object
18 19 20 |
# File 'lib/exif_datify.rb', line 18 def quiet! @quiet = true end |
#rename(file_path) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/exif_datify.rb', line 30 def rename(file_path) @counters[:total] += 1 unless File.basename(file_path) =~ DATETIME_REGEX prepend_date(file_path) end end |