Class: IisObjectCollection
- Inherits:
-
Object
- Object
- IisObjectCollection
- Defined in:
- lib/inetmgr/iis_object_collection.rb
Overview
Represents a collection of IIS configuration objects.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #add {|added| ... } ⇒ Object
- #count ⇒ Object
- #each ⇒ Object
- #exists(name) ⇒ Object
- #find ⇒ Object
-
#initialize(element, item_name, type, add_callback = nil) ⇒ IisObjectCollection
constructor
A new instance of IisObjectCollection.
- #remove(index) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(element, item_name, type, add_callback = nil) ⇒ IisObjectCollection
Returns a new instance of IisObjectCollection.
4 5 6 7 8 9 |
# File 'lib/inetmgr/iis_object_collection.rb', line 4 def initialize element, item_name, type, add_callback = nil @collection_element = element @item_name = item_name @type = type @add_callback = add_callback end |
Instance Method Details
#[](index) ⇒ Object
19 20 21 |
# File 'lib/inetmgr/iis_object_collection.rb', line 19 def [](index) return @type.new @collection_element.Item index end |
#add {|added| ... } ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/inetmgr/iis_object_collection.rb', line 27 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 |
#count ⇒ Object
15 16 17 |
# File 'lib/inetmgr/iis_object_collection.rb', line 15 def count size end |
#each ⇒ Object
23 24 25 |
# File 'lib/inetmgr/iis_object_collection.rb', line 23 def each size.times { |i| yield self[i] } end |
#exists(name) ⇒ Object
44 45 46 |
# File 'lib/inetmgr/iis_object_collection.rb', line 44 def exists(name) !(find {|s| s.name == name}).nil? end |
#find ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/inetmgr/iis_object_collection.rb', line 36 def find size.times do |i| instance = self[i] return instance if yield(instance) end nil end |
#remove(index) ⇒ Object
48 49 50 |
# File 'lib/inetmgr/iis_object_collection.rb', line 48 def remove(index) @collection_element.DeleteElement index end |
#size ⇒ Object
11 12 13 |
# File 'lib/inetmgr/iis_object_collection.rb', line 11 def size @collection_element.Count end |