Sha256: 967fd0b952e9ea9e7ac2e2286d49e6cd6d25e06c359b06bf8111966c1a5bbedc
Contents?: true
Size: 990 Bytes
Versions: 4
Compression:
Stored size: 990 Bytes
Contents
# Represents a collection of IIS configuration objects. class IisObjectCollection def initialize element, item_name, type, add_callback = nil @collection_element = element @item_name = item_name @type = type @add_callback = add_callback end def size @collection_element.Count end def count size end def [](index) return @type.new @collection_element.Item index end def each size.times { |i| yield self[i] } end def add e = @collection_element.CreateNewElement @item_name.to_s added = @type.new e @add_callback.call added unless @add_callback.nil? yield added @collection_element.AddElement e added end def find size.times do |i| instance = self[i] return instance if yield(instance) end nil end def exists(name) !(find {|s| s.name == name}).nil? end def remove(index) @collection_element.DeleteElement index end end
Version data entries
4 entries across 4 versions & 1 rubygems