class TDP::PatchSet
A set of patches.
Public Class Methods
new()
click to toggle source
# File lib/tdp.rb, line 151 def initialize @patches = {} end
Public Instance Methods
<<(patch)
click to toggle source
Adds a patch to the set. Raises ContradictionError
in case if patch set already contains a patch with the same name and different content.
- patch
-
Patch
object to add
# File lib/tdp.rb, line 162 def <<(patch) known_patch = @patches[patch.name] if known_patch.nil? @patches[patch.name] = patch elsif patch.content != known_patch.content raise ContradictionError, [known_patch, patch] end end
[](name)
click to toggle source
Retrieves Patch
by name. If there's no patch with this name, returns nil.
# File lib/tdp.rb, line 197 def [](name) @patches[name] end
each() { |patch| ... }
click to toggle source
Calls the given block once for each patch in collection, passing that element as a parameter.
Ordering of the patches is: first, all permanent patches alphanumerically sorted by name, then all volatile patches sorted in the same way.
# File lib/tdp.rb, line 179 def each @patches.values.sort.each { |patch| yield patch } end
select() { |patch| ... }
click to toggle source
Returns an array of patches for which given block returns a true value.
Ordering of patches is same as in self.each method.
# File lib/tdp.rb, line 189 def select @patches.values.sort.select { |patch| yield patch } end