Class: ExifGpsInjector::Media
- Inherits:
-
Object
- Object
- ExifGpsInjector::Media
- Defined in:
- lib/exif_gps_injector/media.rb
Overview
Media
Instance Attribute Summary collapse
-
#exif ⇒ Object
readonly
Returns the value of attribute exif.
Instance Method Summary collapse
-
#initialize(file) ⇒ Media
constructor
A new instance of Media.
- #location ⇒ Object
- #location=(options) ⇒ Object
- #original_date_time ⇒ Object
- #original_date_time=(value) ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(file) ⇒ Media
Returns a new instance of Media.
6 7 8 |
# File 'lib/exif_gps_injector/media.rb', line 6 def initialize(file) @exif = MiniExiftool.new(file) end |
Instance Attribute Details
#exif ⇒ Object (readonly)
Returns the value of attribute exif.
4 5 6 |
# File 'lib/exif_gps_injector/media.rb', line 4 def exif @exif end |
Instance Method Details
#location ⇒ Object
27 28 29 |
# File 'lib/exif_gps_injector/media.rb', line 27 def location { latitude: @exif.gps_latitude, longitude: @exif.gps_longitude } end |
#location=(options) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/exif_gps_injector/media.rb', line 31 def location=() @exif.gps_latitude = [:gps_latitude] @exif.gps_longitude = [:gps_longitude] @exif.gps_altitude = [:gps_altitude] || 0 @exif.gps_latitude_ref = [:gps_latitude_ref] || 'South' @exif.gps_longitude_ref = [:gps_longitude_ref] || 'West' @exif.save end |
#original_date_time ⇒ Object
14 15 16 |
# File 'lib/exif_gps_injector/media.rb', line 14 def original_date_time @original_date_time ||= @exif.date_time_original || @exif.create_date || @exif.modify_date end |
#original_date_time=(value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/exif_gps_injector/media.rb', line 18 def original_date_time=(value) date = DateTime.parse(value).strftime @exif.date_time_original = date @exif.create_date = date @exif.modify_date = date @exif.save value end |
#tags ⇒ Object
10 11 12 |
# File 'lib/exif_gps_injector/media.rb', line 10 def @exif..map { |e| [e, @exif[e]] }.to_h end |