Class: Inetmgr::IisObjectCollection
- Inherits:
-
Object
- Object
- Inetmgr::IisObjectCollection
- Includes:
- Enumerable
- 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.
6 7 8 9 10 11 |
# File 'lib/inetmgr/iis_object_collection.rb', line 6 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
21 22 23 |
# File 'lib/inetmgr/iis_object_collection.rb', line 21 def [](index) return @type.new @collection_element.Item index end |
#add {|added| ... } ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/inetmgr/iis_object_collection.rb', line 29 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
17 18 19 |
# File 'lib/inetmgr/iis_object_collection.rb', line 17 def count size end |
#each ⇒ Object
25 26 27 |
# File 'lib/inetmgr/iis_object_collection.rb', line 25 def each size.times { |i| yield self[i] } end |
#exists(name) ⇒ Object
46 47 48 |
# File 'lib/inetmgr/iis_object_collection.rb', line 46 def exists(name) !(find {|s| s.name == name}).nil? end |
#find ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/inetmgr/iis_object_collection.rb', line 38 def find size.times do |i| instance = self[i] return instance if yield(instance) end nil end |
#remove(index) ⇒ Object
50 51 52 |
# File 'lib/inetmgr/iis_object_collection.rb', line 50 def remove(index) @collection_element.DeleteElement index end |
#size ⇒ Object
13 14 15 |
# File 'lib/inetmgr/iis_object_collection.rb', line 13 def size @collection_element.Count end |