Class: Aardi::Year
Instance Attribute Summary
Attributes inherited from AbstractBlog
#key
Instance Method Summary
collapse
#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
|
#content ⇒ Object
21
22
23
|
# File 'lib/aardi/year.rb', line 21
def content
"# #{title}\n#{months.map { |month| month_link(month) }.join("\n")}"
end
|
#target_path ⇒ Object
25
26
27
|
# File 'lib/aardi/year.rb', line 25
def target_path
"./#{@archive_path}/#{self}/index.html"
end
|