Class: Usmu::Collections

Inherits:
Object
  • Object
show all
Defined in:
lib/usmu/collections.rb

Defined Under Namespace

Classes: Collection

Instance Method Summary collapse

Constructor Details

#initialize(generator) ⇒ Collections

Returns a new instance of Collections.

Parameters:



5
6
7
8
# File 'lib/usmu/collections.rb', line 5

def initialize(generator)
  @generator = generator
  refresh
end

Instance Method Details

#[](index) ⇒ void



10
11
12
13
14
15
16
17
# File 'lib/usmu/collections.rb', line 10

def [](index)
  unless @collections[index]
    files = @generator.renderables.select {|r| r['collection'] == index }.sort_by &:date
    @collections[index] = Collection.new(files)
  end

  @collections[index]
end

#refreshvoid



19
20
21
# File 'lib/usmu/collections.rb', line 19

def refresh
  @collections = {}
end