Class: Aardi::Day

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

Overview

:reek:TooManyInstanceVariables

Instance Attribute Summary

Attributes inherited from AbstractBlog

#key

Instance Method Summary collapse

Methods inherited from AbstractBlog

#metadata, #mtime, #render, #title

Constructor Details

#initialize(year, month, key, archive_path, tag = nil) ⇒ Day

Returns a new instance of Day.



6
7
8
9
10
11
12
13
# File 'lib/aardi/day.rb', line 6

def initialize(year, month, key, archive_path, tag = nil)
  @year = year
  @month = month
  @key = key
  @archive_path = archive_path
  @tag = tag
  @posts = []
end

Instance Method Details

#<<(post) ⇒ Object



15
16
17
# File 'lib/aardi/day.rb', line 15

def <<(post)
  @posts << post
end

#contentObject



19
20
21
22
23
24
25
# File 'lib/aardi/day.rb', line 19

def content
  @content ||= begin
    sorted_posts = @posts.sort_by(&:creation)
    posts_content = sorted_posts.reverse.map(&:content)
    "# #{title}\n#{posts_content.join}"
  end
end

#countObject



27
# File 'lib/aardi/day.rb', line 27

def count = @posts.count

#target_pathObject



29
30
31
# File 'lib/aardi/day.rb', line 29

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