Class: OakTree::Template::PostArchive

Inherits:
Base
  • Object
show all
Defined in:
lib/oaktree/template/post_archive.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_DATETIME_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#proc_for_datetime

Constructor Details

#initialize(year = 1, month = 1, posts = [], spec, blog) {|_self| ... } ⇒ PostArchive

Returns a new instance of PostArchive.

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/oaktree/template/post_archive.rb', line 20

def initialize year=1, month=1, posts=[], spec, blog
  @year = year
  @month = month
  @posts = posts
  @spec = spec
  @blog = blog
  @datetime = DateTime.new(year, month, 1)
  formatted_date = @datetime.strftime(@spec.date_path_format)
  @permalink = "#{@spec.base_url}#{@spec.post_path}#{formatted_date}"

  yield self if block_given?
end

Instance Attribute Details

#monthObject

Returns the value of attribute month.



13
14
15
# File 'lib/oaktree/template/post_archive.rb', line 13

def month
  @month
end

#next_archiveObject

the next most recent archive



16
17
18
# File 'lib/oaktree/template/post_archive.rb', line 16

def next_archive
  @next_archive
end

#postsObject

Returns the value of attribute posts.



14
15
16
# File 'lib/oaktree/template/post_archive.rb', line 14

def posts
  @posts
end

#previous_archiveObject

the next oldest archive



18
19
20
# File 'lib/oaktree/template/post_archive.rb', line 18

def previous_archive
  @previous_archive
end

#yearObject

Returns the value of attribute year.



12
13
14
# File 'lib/oaktree/template/post_archive.rb', line 12

def year
  @year
end

Instance Method Details

#dateObject



33
34
35
# File 'lib/oaktree/template/post_archive.rb', line 33

def date
  proc_for_datetime(@datetime)
end

#datetimeObject



37
38
39
# File 'lib/oaktree/template/post_archive.rb', line 37

def datetime
  @datetime
end

#open?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/oaktree/template/post_archive.rb', line 45

def open?
  self == @blog.archive
end


41
42
43
# File 'lib/oaktree/template/post_archive.rb', line 41

def permalink
  @permalink
end