Class | RSCM::Revisions |
In: |
lib/rscm/revision.rb
|
Parent: | Object |
A collection of Revision.
revisions | [RW] |
# File lib/rscm/revision.rb, line 12 12: def initialize(revisions=[]) 13: @revisions = revisions 14: end
# File lib/rscm/revision.rb, line 47 47: def ==(other) 48: return false if !other.is_a?(self.class) 49: @revisions == other.revisions 50: end
Accepts a visitor that will receive callbacks while iterating over this instance’s internal structure. The visitor should respond to the following methods:
# File lib/rscm/revision.rb, line 24 24: def accept(visitor) 25: visitor.visit_revisions(self) 26: self.each{|revision| revision.accept(visitor)} 27: end
Adds a File or a Revision. If the argument is a File and no corresponding Revision exists, a new Revision is created, added, and the File is added to that Revision - and then finally the newly created Revision is returned. Otherwise nil is returned.
# File lib/rscm/revision.rb, line 80 80: def add(file_or_revision) 81: if(file_or_revision.is_a?(Revision)) 82: @revisions << file_or_revision 83: return file_or_revision 84: else 85: revision = @revisions.find { |a_revision| a_revision.can_contain?(file_or_revision) } 86: if(revision.nil?) 87: revision = Revision.new 88: @revisions << revision 89: revision << file_or_revision 90: return revision 91: end 92: revision << file_or_revision 93: return nil 94: end 95: end
# File lib/rscm/revision.rb, line 97 97: def push(*file_or_revisions) 98: file_or_revisions.each { |file_or_revision| self << (file_or_revision) } 99: self 100: end