Class: Prick::Diff
- Inherits:
-
Object
- Object
- Prick::Diff
- Defined in:
- lib/prick/diff.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(db1, db2) ⇒ Diff
constructor
A new instance of Diff.
-
#read ⇒ Object
Return the diff between the two databases or nil if they’re equal.
-
#same? ⇒ Boolean
Return true if the two databases are equal.
-
#write(file) ⇒ Object
Write the diff between the databases to the given file.
Constructor Details
#initialize(db1, db2) ⇒ Diff
Returns a new instance of Diff.
3 4 5 6 7 8 |
# File 'lib/prick/diff.rb', line 3 def initialize(db1, db2) @db1, @db2 = db1, db2 @diffed = false @diff = nil @result = nil end |
Class Method Details
.same?(db1, db2) ⇒ Boolean
10 |
# File 'lib/prick/diff.rb', line 10 def self.same?(db1, db2) Diff.new(db1, db2).same? end |
Instance Method Details
#read ⇒ Object
Return the diff between the two databases or nil if they’re equal
20 21 22 |
# File 'lib/prick/diff.rb', line 20 def read @diffed ? @diff : do_diff end |
#same? ⇒ Boolean
Return true if the two databases are equal. Named #same? to avoid name collision with the built in #equal?
14 15 16 17 |
# File 'lib/prick/diff.rb', line 14 def same? do_diff if @result.nil? @result end |
#write(file) ⇒ Object
Write the diff between the databases to the given file. Return true if the databases are equal
26 27 28 29 30 31 32 33 |
# File 'lib/prick/diff.rb', line 26 def write(file) if @diffed IO.write(file, @diff) else do_diff(file) end @result end |