Method: Nanoc::Core::BasicItemView#children

Defined in:
lib/nanoc/core/basic_item_view.rb

#childrenEnumerable<Nanoc::Core::CompilationItemView>

Returns the children of this item. For items with identifiers that have extensions, returns an empty collection.



12
13
14
15
16
17
18
19
20
21
# File 'lib/nanoc/core/basic_item_view.rb', line 12

def children
  unless _unwrap.identifier.legacy?
    raise Nanoc::Core::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(_unwrap.identifier)
  end

  children_pattern = Nanoc::Core::Pattern.from(_unwrap.identifier.to_s + '*/')
  children = @context.items.select { |i| children_pattern.match?(i.identifier) }

  children.map { |i| self.class.new(i, @context) }.freeze
end