Class: Cloudpress::Renderers::Posts

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudpress/renderers/posts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @context = context
  @posts   = posts
  @options = options.reverse_merge default_options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/cloudpress/renderers/posts.rb', line 5

def options
  @options
end

#postsObject (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

#renderObject



17
18
19
20
21
# File 'lib/cloudpress/renderers/posts.rb', line 17

def render
  @context.(:div, id: 'post-list') do
    wrapped_posts.map(&:render).join("\n").html_safe
  end
end

#tags?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cloudpress/renderers/posts.rb', line 23

def tags?
  options[:tags]
end

#wrapped_postsObject



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, options)}
end