Class: Aardi::Month
Instance Attribute Summary
Attributes inherited from AbstractBlog
#key
Instance Method Summary
collapse
#metadata, #mtime, #render
Constructor Details
#initialize(year, key, archive_path) ⇒ Month
Returns a new instance of Month.
5
6
7
8
9
10
|
# File 'lib/aardi/month.rb', line 5
def initialize(year, key, archive_path)
@year = year
@key = key
@archive_path = archive_path
@index = Hash.new { |hash, day| hash[day] = Day.new(year, self, day, archive_path) }
end
|
Instance Method Details
#<<(post) ⇒ Object
12
13
14
|
# File 'lib/aardi/month.rb', line 12
def <<(post)
@index[post.day] << post
end
|
#archive_cell(month_fmt) ⇒ Object
16
17
18
19
|
# File 'lib/aardi/month.rb', line 16
def archive_cell(month_fmt)
cell = count.zero? ? '' : format(month_fmt, count:, archive_path: @archive_path, year: @year, month: self)
"#{cell} |"
end
|
#content ⇒ Object
21
22
23
24
25
26
|
# File 'lib/aardi/month.rb', line 21
def content
@content ||= begin
days_content = days.map { |day| "##{day.content}" }.join
"# #{title}\n#{days_content}"
end
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
|
#title ⇒ Object
34
|
# File 'lib/aardi/month.rb', line 34
def title = Date.new(@year.key, @key).strftime('%B %Y')
|
#to_s ⇒ Object
36
|
# File 'lib/aardi/month.rb', line 36
def to_s = @key.to_s.rjust(2, '0')
|