Method: Nanoc::Core::BasicItemRepCollectionView#fetch

Defined in:
lib/nanoc/core/views/basic_item_rep_collection_view.rb

#fetch(rep_name) ⇒ Nanoc::Core::BasicItemRepView

Return the item rep with the given name, or raises an exception if there is no rep with the given name.

Parameters:

  • rep_name (Symbol)

Returns:

Raises:

  • if no rep was found



78
79
80
81
82
83
84
85
# File 'lib/nanoc/core/views/basic_item_rep_collection_view.rb', line 78

def fetch(rep_name)
  res = @item_reps.find { |ir| ir.name == rep_name }
  if res
    view_class.new(res, @context)
  else
    raise NoSuchItemRepError.new(rep_name)
  end
end