Class: Obst::LastSeen

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/obst/last_seen.rb

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ LastSeen

Returns a new instance of LastSeen.



8
9
10
# File 'lib/obst/last_seen.rb', line 8

def initialize(**opts)
  @groups = Obst::GroupByDays.new(**opts)
end

Instance Method Details

#each(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/obst/last_seen.rb', line 12

def each(&block)
  return self unless block

  seen = Set.new
  @groups.each do |record|
    record.file_changes.keys.each do |file|
      if seen.include?(file)
        record.file_changes.delete(file)
      else
        seen << file
      end
    end
    block.call(record)
  end
end