class Build::Dependency::Set
Very similar to a set but uses a specific callback (defaults to &:name) for object identity.
Attributes
table[R]
Public Class Methods
new(contents = [])
click to toggle source
# File lib/build/dependency/set.rb, line 29 def initialize(contents = []) @table = {} contents.each do |object| add(object) end end
Public Instance Methods
add(object)
click to toggle source
# File lib/build/dependency/set.rb, line 59 def add(object) if include?(object) raise KeyError, "Object #{identity(object)} already exists!" end @table[identity(object)] = object end
Also aliased as: <<
delete(object)
click to toggle source
# File lib/build/dependency/set.rb, line 69 def delete(object) @table.delete(identity(object)) end
each(&block)
click to toggle source
# File lib/build/dependency/set.rb, line 77 def each(&block) @table.each_value(&block) end
freeze()
click to toggle source
Calls superclass method
# File lib/build/dependency/set.rb, line 43 def freeze return self if frozen? @table.freeze super end
identity(object)
click to toggle source
# File lib/build/dependency/set.rb, line 55 def identity(object) object.name end
include?(object)
click to toggle source
# File lib/build/dependency/set.rb, line 73 def include?(object) @table.include?(identity(object)) end
initialize_dup(other)
click to toggle source
# File lib/build/dependency/set.rb, line 51 def initialize_dup(other) @table = other.table.dup end
slice(names)
click to toggle source
# File lib/build/dependency/set.rb, line 81 def slice(names) names.collect{|name| @table[name]} end