Class: 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
-
#[](arg) ⇒ Object
-
#each {|object| ... } ⇒ self
Calls the given block once for each object, passing that object as a parameter.
-
#find_all(arg) ⇒ Enumerable
Finds all objects whose identifier matches the given argument.
-
#size ⇒ Integer
Methods inherited from View
Instance Method Details
#[](string) ⇒ nil, #identifier #[](regex) ⇒ nil, #identifier
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 |
#each {|object| ... } ⇒ self
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 |
#find_all(arg) ⇒ Enumerable
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 |
#size ⇒ Integer
36 37 38 |
# File 'lib/nanoc/base/views/identifiable_collection_view.rb', line 36 def size @objects.size end |