Class: SpecViews::BatchDiff::Change

Inherits:
Struct
  • Object
show all
Defined in:
app/models/spec_views/batch_diff.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



7
8
9
# File 'app/models/spec_views/batch_diff.rb', line 7

def count
  @count
end

#hashObject

Returns the value of attribute hash

Returns:

  • (Object)

    the current value of hash



7
8
9
# File 'app/models/spec_views/batch_diff.rb', line 7

def hash
  @hash
end

Instance Method Details

#accept!Object



30
31
32
33
34
35
36
# File 'app/models/spec_views/batch_diff.rb', line 30

def accept!
  @pairs.each do |directory, diff|
    patched_champion = Diff::LCS.patch!(directory.champion_html, diff)
    directory.write_champion(patched_champion)
    directory.remove_challenger if patched_champion == directory.challenger_html
  end
end

#add(directory, diff) ⇒ Object



16
17
18
19
20
# File 'app/models/spec_views/batch_diff.rb', line 16

def add(directory, diff)
  @pairs ||= []
  @pairs.push([directory, diff])
  self.count += 1
end

#championObject



12
13
14
# File 'app/models/spec_views/batch_diff.rb', line 12

def champion
  directory.champion_html
end

#diffObject



26
27
28
# File 'app/models/spec_views/batch_diff.rb', line 26

def diff
  @pairs&.first&.second
end

#directoryObject



22
23
24
# File 'app/models/spec_views/batch_diff.rb', line 22

def directory
  @pairs&.first&.first
end

#patched_championObject



8
9
10
# File 'app/models/spec_views/batch_diff.rb', line 8

def patched_champion
  Diff::LCS.patch!(champion, diff)
end