class PhotoGeoloader
Attributes
attributes[RW]
data[RW]
photo_path[RW]
position[RW]
Public Class Methods
new(photo_path, attributes = [:latitude, :longitude, :altitude])
click to toggle source
# File lib/photo_geoloader.rb, line 7 def initialize(photo_path, attributes = [:latitude, :longitude, :altitude]) self.photo_path = photo_path self.attributes = attributes self.position = {} load_exif_data end
Public Instance Methods
load_exif_data()
click to toggle source
# File lib/photo_geoloader.rb, line 14 def load_exif_data self.data = EXIFR::JPEG.new(photo_path).exif.to_a.first attributes.each do |attr| self.position[attr.to_sym] = data.fields[:gps].fields["gps_#{attr}".to_sym].to_f end end
place_attributes(model)
click to toggle source
# File lib/photo_geoloader.rb, line 21 def place_attributes(model) success = false attributes.each do |attr| if model.respond_to? attr model.send "#{attr}=".to_sym, position[attr.to_sym] success = true end end success end