Class: Akki::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/akki/article.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Article

Returns a new instance of Article.



7
8
9
10
11
12
# File 'lib/akki/article.rb', line 7

def initialize(params)
  @title   = params[:title]
  @date    = params[:date]
  @content = params[:content]
  @slug = params[:slug]
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/akki/article.rb', line 5

def content
  @content
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/akki/article.rb', line 5

def date
  @date
end

#slugObject

Returns the value of attribute slug.



5
6
7
# File 'lib/akki/article.rb', line 5

def slug
  @slug
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/akki/article.rb', line 5

def title
  @title
end

Class Method Details

.allObject



19
20
21
22
23
24
# File 'lib/akki/article.rb', line 19

def all
  unless defined? @articles
    @articles = get_all_articles
  end
  @articles
end

.find(year, month, day, slug) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/akki/article.rb', line 26

def find year, month, day, slug
  article = all.select { |article|
    article.date.year  == year  &&
    article.date.month == month &&
    article.date.day   == day   &&
    article.slug       == slug
  }.first
end

Instance Method Details

#pathObject



14
15
16
# File 'lib/akki/article.rb', line 14

def path
  date.strftime("/%Y/%m/%d/") + slug
end