25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/simpleblog.rb', line 25
def self.list_articles(tag = "", in_progress: "true")
articles_yml_result = YAML.load_file("app/articles/articles.yml")["articles"]
articles = Article.build_list_of_articles(articles_yml_result)
if tag.present?
articles = articles.filter { |article| article.tags.include?(tag) }
end
if in_progress == "true"
articles = articles.filter { |article| article.in_progress }
else
articles = articles.filter { |article| !article.in_progress }
end
articles.sort_by(&:id).reverse!
end
|