Class: Kublog::PostsPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/kublog/posts_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category = nil) ⇒ PostsPresenter

Returns a new instance of PostsPresenter.



6
7
8
# File 'app/presenters/kublog/posts_presenter.rb', line 6

def initialize(category=nil)
  @category = category
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'app/presenters/kublog/posts_presenter.rb', line 4

def category
  @category
end

Instance Method Details

#categoriesObject



10
11
12
# File 'app/presenters/kublog/posts_presenter.rb', line 10

def categories
  @categories ||= Category.all
end

#descriptionObject



22
23
24
# File 'app/presenters/kublog/posts_presenter.rb', line 22

def description
  @description = @category.nil? ? Kublog.blog_description : "#{@category.name} :: #{Kublog.blog_name} :: #{Kublog.blog_description}"
end

#ftime(updated) ⇒ Object



30
31
32
# File 'app/presenters/kublog/posts_presenter.rb', line 30

def ftime(updated)
  updated.strftime("%Y-%m-%dT%H:%M:%SZ")
end

#postsObject



14
15
16
# File 'app/presenters/kublog/posts_presenter.rb', line 14

def posts
  @posts ||= @category ? @category.posts : Post.all
end

#titleObject



18
19
20
# File 'app/presenters/kublog/posts_presenter.rb', line 18

def title
  @title ||= @category.nil? ? Kublog.blog_name : "#{@category.name} :: #{Kublog.blog_name}"
end

#updatedObject



26
27
28
# File 'app/presenters/kublog/posts_presenter.rb', line 26

def updated
  self.posts.first.try(:updated_at) - 1.seconds
end