Class: Nanoc::IdentifiableCollectionView
- Inherits:
-
View
- Object
- View
- Nanoc::IdentifiableCollectionView
- Includes:
- Enumerable
- Defined in:
- lib/nanoc/base/views/identifiable_collection_view.rb
Direct Known Subclasses
ItemCollectionWithRepsView, ItemCollectionWithoutRepsView, LayoutCollectionView, MutableIdentifiableCollectionView, PostCompileItemCollectionView
Instance Method Summary (collapse)
-
- (Object) [](arg)
-
- (self) each {|object| ... }
Calls the given block once for each object, passing that object as a parameter.
-
- (Enumerable) find_all(arg)
Finds all objects whose identifier matches the given argument.
-
- (Integer) size
Methods inherited from View
Instance Method Details
- (nil, #identifier) [](string) - (nil, #identifier) [](regex)
72 73 74 75 |
# File 'lib/nanoc/base/views/identifiable_collection_view.rb', line 72 def [](arg) res = @objects[arg] res && view_class.new(res, @context) end |
- (self) each {|object| ... }
Calls the given block once for each object, passing that object as a parameter.
30 31 32 33 |
# File 'lib/nanoc/base/views/identifiable_collection_view.rb', line 30 def each @objects.each { |i| yield view_class.new(i, @context) } self end |
- (Enumerable) find_all(arg)
Finds all objects whose identifier matches the given argument.
45 46 47 48 |
# File 'lib/nanoc/base/views/identifiable_collection_view.rb', line 45 def find_all(arg) pat = Nanoc::Int::Pattern.from(arg) select { |i| pat.match?(i.identifier) } end |
- (Integer) size
36 37 38 |
# File 'lib/nanoc/base/views/identifiable_collection_view.rb', line 36 def size @objects.size end |