class Rollin::Blog
Public Class Methods
new(options = {})
click to toggle source
# File lib/rollin/blog.rb, line 2 def initialize(options = {}) @articles_folder = options[:articles_folder] || 'articles' end
Public Instance Methods
annual_archive()
click to toggle source
# 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 = {})
click to toggle source
# File lib/rollin/blog.rb, line 6 def article(search = {}) unfiltered_articles.find { |article| article.matches?(search) } end
articles(search = {})
click to toggle source
# File lib/rollin/blog.rb, line 10 def articles(search = {}) unfiltered_articles.select { |article| article.matches?(search) } end
monthly_archive()
click to toggle source
# 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()
click to toggle source
# File lib/rollin/blog.rb, line 14 def unfiltered_articles read_articles.reverse end
Private Instance Methods
read_articles()
click to toggle source
# File lib/rollin/blog.rb, line 50 def read_articles extensions = %w{markdown mdown mkdn md mkd mdwn mdtxt mdtext text} Dir[*extensions.map { |ext| "#{@articles_folder}/**/*.#{ext}" }].sort.map do |article_source| Rollin::Article.new(article_source) end end