Class: Writetheman::Blog

Inherits:
Object
  • Object
show all
Includes:
Path
Defined in:
lib/writetheman/blog.rb

Instance Attribute Summary

Attributes included from Path

#path_application

Instance Method Summary collapse

Constructor Details

#initialize(path_application) ⇒ Blog

Returns a new instance of Blog.



6
7
8
# File 'lib/writetheman/blog.rb', line 6

def initialize(path_application)
  @path_application = path_application
end

Instance Method Details

#list_articlesObject



16
17
18
19
20
21
22
# File 'lib/writetheman/blog.rb', line 16

def list_articles
  articles = []
  list_source_files.each do |filepath|
    articles << new_article(Pathname.new(filepath).basename.to_s)
  end
  articles
end

#new_article(filename = '') ⇒ Object



10
11
12
13
14
# File 'lib/writetheman/blog.rb', line 10

def new_article(filename='')
  article = Article::Base.new(@path_application)
  article.load_from_file(filename) if !filename.empty?
  article
end