Class: Kublog::PostsPresenter
- Inherits:
-
Object
- Object
- Kublog::PostsPresenter
- Defined in:
- app/presenters/kublog/posts_presenter.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
Instance Method Summary collapse
- #categories ⇒ Object
- #description ⇒ Object
- #ftime(updated) ⇒ Object
-
#initialize(category = nil) ⇒ PostsPresenter
constructor
A new instance of PostsPresenter.
- #posts ⇒ Object
- #title ⇒ Object
- #updated ⇒ Object
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
#category ⇒ Object
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
#categories ⇒ Object
10 11 12 |
# File 'app/presenters/kublog/posts_presenter.rb', line 10 def categories @categories ||= Category.all end |
#description ⇒ Object
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 |
#posts ⇒ Object
14 15 16 |
# File 'app/presenters/kublog/posts_presenter.rb', line 14 def posts @posts ||= @category ? @category.posts : Post.all end |
#title ⇒ Object
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 |
#updated ⇒ Object
26 27 28 |
# File 'app/presenters/kublog/posts_presenter.rb', line 26 def updated self.posts.first.try(:updated_at) - 1.seconds end |