Class: Aardi::Year

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

Instance Attribute Summary

Attributes inherited from AbstractBlog

#key

Instance Method Summary collapse

Methods inherited from AbstractBlog

#metadata, #mtime, #render, #title

Constructor Details

#initialize(key, archive_path, tag = nil) ⇒ Year

Returns a new instance of Year.



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

def initialize(key, archive_path, tag = nil)
  @key = key
  @archive_path = archive_path
  @index = Hash.new { |hash, month| hash[month] = Month.new(self, month, archive_path, tag) }
  @tag = tag
end

Instance Method Details

#<<(post) ⇒ Object



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

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

#archive_row(year_fmt, month_fmt) ⇒ Object



16
17
18
19
# File 'lib/aardi/year.rb', line 16

def archive_row(year_fmt, month_fmt)
  months_map = (1..12).map { |month| @index[month].archive_cell(month_fmt) }.join
  format(year_fmt, year: to_s, months: months_map)
end

#contentObject



21
22
23
# File 'lib/aardi/year.rb', line 21

def content
  "# #{title}\n#{months.map { |month| month_link(month) }.join("\n")}"
end

#target_pathObject



25
26
27
# File 'lib/aardi/year.rb', line 25

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