Class: Puppet::FileCollection
Overview
A simple way to turn file names into singletons, so we don’t have tons of copies of each file path around.
Defined Under Namespace
Modules: Lookup
Class Method Summary collapse
Instance Method Summary collapse
- #index(path) ⇒ Object
-
#initialize ⇒ FileCollection
constructor
A new instance of FileCollection.
- #path(index) ⇒ Object
Constructor Details
#initialize ⇒ FileCollection
Returns a new instance of FileCollection.
10 11 12 13 |
# File 'lib/puppet/file_collection.rb', line 10 def initialize @paths = [] @inverse = {} end |
Class Method Details
.collection ⇒ Object
6 7 8 |
# File 'lib/puppet/file_collection.rb', line 6 def self.collection @collection end |
Instance Method Details
#index(path) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/puppet/file_collection.rb', line 15 def index(path) if i = @inverse[path] return i else @paths << path i = @inverse[path] = @paths.length - 1 return i end end |
#path(index) ⇒ Object
25 26 27 |
# File 'lib/puppet/file_collection.rb', line 25 def path(index) @paths[index] end |