Class: Aardi::Month
Overview
:reek:TooManyInstanceVariables
Instance Attribute Summary
Attributes inherited from AbstractBlog
#key
Instance Method Summary
collapse
#metadata, #mtime, #render, #title
Constructor Details
#initialize(year, key, archive_path, tag = nil) ⇒ Month
Returns a new instance of Month.
6
7
8
9
10
11
12
|
# File 'lib/aardi/month.rb', line 6
def initialize(year, key, archive_path, tag = nil)
@year = year
@key = key
@archive_path = archive_path
@index = Hash.new { |hash, day| hash[day] = Day.new(year, self, day, archive_path, tag) }
@tag = tag
end
|
Instance Method Details
#<<(post) ⇒ Object
14
15
16
|
# File 'lib/aardi/month.rb', line 14
def <<(post)
@index[post.creation.day] << post
end
|
#archive_cell(month_fmt) ⇒ Object
18
19
20
21
22
|
# File 'lib/aardi/month.rb', line 18
def archive_cell(month_fmt)
return ' |' if count.zero?
"#{format(month_fmt, count:, archive_path: @archive_path, year: @year, month: self)} |"
end
|
#content ⇒ Object
24
25
26
|
# File 'lib/aardi/month.rb', line 24
def content
@content ||= "# #{title}\n#{days.map { |day| "##{day.content}" }.join}"
end
|
#count ⇒ Object
28
|
# File 'lib/aardi/month.rb', line 28
def count = days.sum(&:count)
|
#target_path ⇒ Object
30
31
32
|
# File 'lib/aardi/month.rb', line 30
def target_path
"./#{@archive_path}/#{@year}/#{self}/index.html"
end
|
#to_s ⇒ Object
34
|
# File 'lib/aardi/month.rb', line 34
def to_s = @key.to_s.rjust(2, '0')
|