Class: Nanoc::Int::ItemRepRepo Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nanoc/base/compilation/item_rep_repo.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Stores item reps (in memory).

Instance Method Summary collapse

Constructor Details

#initializeItemRepRepo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ItemRepRepo.



8
9
10
11
# File 'lib/nanoc/base/compilation/item_rep_repo.rb', line 8

def initialize
  @reps = []
  @reps_by_item = {}
end

Instance Method Details

#<<(rep) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
18
# File 'lib/nanoc/base/compilation/item_rep_repo.rb', line 13

def <<(rep)
  @reps << rep

  @reps_by_item[rep.item] ||= []
  @reps_by_item[rep.item] << rep
end

#[](item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/nanoc/base/compilation/item_rep_repo.rb', line 29

def [](item)
  @reps_by_item.fetch(item, [])
end

#each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
# File 'lib/nanoc/base/compilation/item_rep_repo.rb', line 24

def each(&block)
  @reps.each(&block)
  self
end

#to_aObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/nanoc/base/compilation/item_rep_repo.rb', line 20

def to_a
  @reps
end