Class: Cloudpress::Renderers::Posts
- Inherits:
-
Object
- Object
- Cloudpress::Renderers::Posts
- Defined in:
- lib/cloudpress/renderers/posts.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
Instance Method Summary collapse
-
#initialize(context, posts, options = {}) ⇒ Posts
constructor
A new instance of Posts.
- #render ⇒ Object
- #tags? ⇒ Boolean
- #wrapped_posts ⇒ Object
Constructor Details
#initialize(context, posts, options = {}) ⇒ Posts
Returns a new instance of Posts.
7 8 9 10 11 |
# File 'lib/cloudpress/renderers/posts.rb', line 7 def initialize(context, posts, ={}) @context = context @posts = posts @options = .reverse_merge end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/cloudpress/renderers/posts.rb', line 5 def @options end |
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
5 6 7 |
# File 'lib/cloudpress/renderers/posts.rb', line 5 def posts @posts end |
Instance Method Details
#render ⇒ Object
17 18 19 20 21 |
# File 'lib/cloudpress/renderers/posts.rb', line 17 def render @context.content_tag(:div, id: 'post-list') do wrapped_posts.map(&:render).join("\n").html_safe end end |
#tags? ⇒ Boolean
23 24 25 |
# File 'lib/cloudpress/renderers/posts.rb', line 23 def [:tags] end |
#wrapped_posts ⇒ Object
13 14 15 |
# File 'lib/cloudpress/renderers/posts.rb', line 13 def wrapped_posts @wrapped_posts ||= posts.map {|post| Cloudpress::Renderers::Post.new(@context, post, )} end |