Class: Rollin::Blog
- Inherits:
-
Object
- Object
- Rollin::Blog
- Defined in:
- lib/rollin/blog.rb
Instance Method Summary collapse
- #annual_archive ⇒ Object
- #article(search = {}) ⇒ Object
- #articles(search = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Blog
constructor
A new instance of Blog.
- #metatags ⇒ Object
- #monthly_archive ⇒ Object
- #unfiltered_articles ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Blog
Returns a new instance of Blog.
2 3 4 |
# File 'lib/rollin/blog.rb', line 2 def initialize( = {}) @articles_folder = [:articles_folder] || 'articles' end |
Instance Method Details
#annual_archive ⇒ Object
33 34 35 36 37 |
# File 'lib/rollin/blog.rb', line 33 def annual_archive monthly_archive.map { |month_archive| month_archive.year }.uniq.map do |year| Rollin::YearArchive.new(year, monthly_archive.select { |aMonth| aMonth.year == year }) end end |
#article(search = {}) ⇒ Object
6 7 8 |
# File 'lib/rollin/blog.rb', line 6 def article(search = {}) unfiltered_articles.find { |article| article.matches?(search) } end |
#articles(search = {}) ⇒ Object
10 11 12 |
# File 'lib/rollin/blog.rb', line 10 def articles(search = {}) unfiltered_articles.select { |article| article.matches?(search) } end |
#metatags ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rollin/blog.rb', line 18 def = unfiltered_articles.map do |article| article..keys end.flatten.uniq .map do || values = unfiltered_articles.select { |article| article..has_key?() }.map do |article| article.[] end.flatten.uniq.map do || Rollin::MetatagValue.new(, articles( => )) end Rollin::MetatagKey.new(, values) end end |
#monthly_archive ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/rollin/blog.rb', line 39 def monthly_archive articles.map { |article| [article.year, article.month] }.uniq.map do |year_and_month| year = year_and_month[0] month = year_and_month[1] articles_for_month = articles.select { |anArticle| anArticle.year == year && anArticle.month == month } Rollin::MonthArchive.new(year, month, articles_for_month) end end |
#unfiltered_articles ⇒ Object
14 15 16 |
# File 'lib/rollin/blog.rb', line 14 def unfiltered_articles read_articles.reverse end |