Class: Aardi::Archive

Inherits:
AbstractBlog show all
Defined in:
lib/aardi/archive.rb

Instance Attribute Summary

Attributes inherited from AbstractBlog

#key

Instance Method Summary collapse

Methods inherited from AbstractBlog

#metadata, #mtime, #render, #title

Constructor Details

#initialize(archive_path, tag = nil, tags = nil) ⇒ Archive

Returns a new instance of Archive.



5
6
7
8
9
10
# File 'lib/aardi/archive.rb', line 5

def initialize(archive_path, tag = nil, tags = nil)
  @archive_path = archive_path
  @tag = tag
  @tags = tags
  @index = Hash.new { |hash, year| hash[year] = Year.new(year, @archive_path, @tag) }
end

Instance Method Details

#<<(post) ⇒ Object



12
13
14
# File 'lib/aardi/archive.rb', line 12

def <<(post)
  @index[post.creation.year] << post
end

#contentObject



16
17
18
19
20
21
22
# File 'lib/aardi/archive.rb', line 16

def content
  year_fmt = "| %<year>s | %<months>s \n"
  month_fmt = "[&nbsp;%<count>s&nbsp;](#{Config[:site_url]}/%<archive_path>s/%<year>s/%<month>s/)"

  rows = years.map { |year| year.archive_row(year_fmt, month_fmt) }.join
  "#{title_heading}#{tag_list}**When**:\n\n#{table_header}#{rows}"
end

#target_pathObject



24
# File 'lib/aardi/archive.rb', line 24

def target_path = "./#{@archive_path}/index.html"