Class: Gdshowsdb::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/gdshowsdb/diff.rb

Direct Known Subclasses

SetDiff, ShowDiff, SongDiff, SongRefDiff

Instance Method Summary collapse

Constructor Details

#initialize(from_yaml, from_db) ⇒ Diff

Returns a new instance of Diff.



3
4
5
6
7
8
# File 'lib/gdshowsdb/diff.rb', line 3

def initialize(from_yaml, from_db)
  @from_yaml = from_yaml
  @yaml_uuids = extract_uuids(@from_yaml)
  @from_db = from_db
  @db_uuids = extract_uuids(@from_db)
end

Instance Method Details

#addedObject



10
11
12
13
14
# File 'lib/gdshowsdb/diff.rb', line 10

def added
  (@from_yaml - @from_db).reject do |item|
    @db_uuids.member?(item[:uuid])
  end
end

#removedObject



16
17
18
19
20
# File 'lib/gdshowsdb/diff.rb', line 16

def removed
  (@from_db - @from_yaml).reject do |item|
    @yaml_uuids.member?(item[:uuid])
  end
end

#updatedObject



22
23
24
25
26
# File 'lib/gdshowsdb/diff.rb', line 22

def updated
  (@from_yaml - @from_db).select do |item|
    @yaml_uuids.member?(item[:uuid]) && @db_uuids.member?(item[:uuid])
  end
end