<commit_before>module ExifGpsInjector
  # LocationTracker
  class LocationTracker
    def initialize(file)
      @list = Nokogiri::XML(File.open(file)).search('when')
              .map { |e| { (DateTime.parse(e.text).utc - 2.hours) => e.next_element.text } }
              .reduce({}, :merge)
              .sort.to_h
    end
  end
end<commit_msg>Add locate_at to location_tracker<commit_after>module ExifGpsInjector
  # LocationTracker
  class LocationTracker
    def initialize(file)
      @list = Nokogiri::XML(File.open(file)).search('when')
              .map { |e| { (DateTime.parse(e.text).utc - 2.hours) => e.next_element.text } }
              .reduce({}, :merge)
              .sort.to_h
    end
    def list
      @list
    end

    def self.instance
    end

    def self.locate_at(date)
      instance.list.select{|key, value| key <= date && key >= date - 3.minutes }.to_a.last.last rescue nil ||
        instance.list.select{|key, value| key >= date && key <= date + 3.minutes }.to_a.first.last rescue nil
    end
  end
end
{'fraction_non_alphanumeric': 0.13583815028901733, 'fraction_numerical': 0.0038535645472061657, 'mean_word_length': 2.3733766233766236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6189686', 'n_tokens_mistral': 353, 'n_tokens_neox': 342, 'n_words': 72}