Class: ExifGpsInjector::Kml
- Inherits:
-
Object
- Object
- ExifGpsInjector::Kml
- Defined in:
- lib/exif_gps_injector/kml.rb
Overview
Kml
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#max_distance_time ⇒ Object
Returns the value of attribute max_distance_time.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Kml
constructor
A new instance of Kml.
- #locate_at(date) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Kml
Returns a new instance of Kml.
7 8 9 10 11 12 |
# File 'lib/exif_gps_injector/kml.rb', line 7 def initialize( = {}) @dir = .delete(:dir) @max_distance_time = .delete(:max_distance_time) || 2.minutes @list = {} Dir.glob("#{@dir}/*.kml").each { |kml| @list.merge!(extract_list_from_kml(File.read(kml))) } end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
4 5 6 |
# File 'lib/exif_gps_injector/kml.rb', line 4 def list @list end |
#max_distance_time ⇒ Object
Returns the value of attribute max_distance_time.
5 6 7 |
# File 'lib/exif_gps_injector/kml.rb', line 5 def max_distance_time @max_distance_time end |
Instance Method Details
#locate_at(date) ⇒ Object
14 15 16 17 18 |
# File 'lib/exif_gps_injector/kml.rb', line 14 def locate_at(date) date = DateTime.parse(date).utc @list.select { |key, _value| key <= date && key >= date - @max_distance_time }.to_a.last.try(:last) || @list.select { |key, _value| key >= date && key <= date + @max_distance_time }.to_a.first.try(:last) end |