Sha256: 101b4add5aa8be01f23d254123c987c1830567c24e0c1ace7a9dd61250119bd2
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Inetmgr # Represents a collection of IIS configuration objects. class IisObjectCollection include Enumerable 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inetmgr-0.7.0 | lib/inetmgr/iis_object_collection.rb |