Class: Dandelion::PartialDiff
- Inherits:
-
Object
- Object
- Dandelion::PartialDiff
- Defined in:
- lib/dandelion/diff.rb
Instance Method Summary collapse
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(diff) ⇒ PartialDiff
constructor
A new instance of PartialDiff.
Constructor Details
#initialize(diff) ⇒ PartialDiff
Returns a new instance of PartialDiff.
28 29 30 31 32 33 34 |
# File 'lib/dandelion/diff.rb', line 28 def initialize(diff) @deltas = [] diff.each_delta do |delta| @deltas << delta end end |
Instance Method Details
#each ⇒ Object
40 41 42 43 44 |
# File 'lib/dandelion/diff.rb', line 40 def each deletes, writes = @deltas.partition(&:deleted?) deletes.each { |delta| yield Change.new(delta.old_file[:path], :delete) } writes.each { |delta| yield Change.new(delta.new_file[:path], :write) } end |
#empty? ⇒ Boolean
36 37 38 |
# File 'lib/dandelion/diff.rb', line 36 def empty? @deltas.empty? end |