Class: ArchivePageTreeStructure::ArchiveYearTreePage

Inherits:
ArchiveTreePage show all
Defined in:
lib/archive_page_tree_structure.rb

Instance Method Summary collapse

Methods inherited from ArchiveTreePage

#allowed_children_cache, #children, #class_name, display_name, #sheet?, #status, #url, #virtual?

Constructor Details

#initialize(parent, start_time, end_time = nil) ⇒ ArchiveYearTreePage

Returns a new instance of ArchiveYearTreePage.



68
69
70
71
72
# File 'lib/archive_page_tree_structure.rb', line 68

def initialize(parent, start_time, end_time=nil)
  @parent = parent
  @start_time = start_time
  @end_time = end_time
end

Instance Method Details



79
80
81
# File 'lib/archive_page_tree_structure.rb', line 79

def breadcrumb
  title
end

#idObject



73
74
75
# File 'lib/archive_page_tree_structure.rb', line 73

def id
  @start_time.strftime("#{@parent.id}_%Y")
end

#titleObject



76
77
78
# File 'lib/archive_page_tree_structure.rb', line 76

def title
  @start_time.strftime("%Y")
end

#tree_child(slug) ⇒ Object



90
91
92
# File 'lib/archive_page_tree_structure.rb', line 90

def tree_child(slug)
  ArchiveMonthTreePage.new(@parent, @start_time.beginning_of_year.months_since(slug.to_i - 1))
end

#tree_childrenObject



82
83
84
85
86
87
88
89
# File 'lib/archive_page_tree_structure.rb', line 82

def tree_children
  start_month = @start_time.month
  end_month = 12
  end_month = @end_time.month if @end_time && @end_time.year <= @start_time.year
  (@start_time.month..end_month).map do |m|
    tree_child(m)
  end.reverse
end