Class: Nanoc::Core::ItemRepRepo Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nanoc/core/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.



11
12
13
14
# File 'lib/nanoc/core/item_rep_repo.rb', line 11

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.



16
17
18
19
20
21
# File 'lib/nanoc/core/item_rep_repo.rb', line 16

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.



32
33
34
# File 'lib/nanoc/core/item_rep_repo.rb', line 32

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

#eachObject

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.



27
28
29
30
# File 'lib/nanoc/core/item_rep_repo.rb', line 27

def each(&)
  @reps.each(&)
  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.



23
24
25
# File 'lib/nanoc/core/item_rep_repo.rb', line 23

def to_a
  @reps
end