Class: Statikaj::Render

Inherits:
Object show all
Defined in:
lib/statikaj/render.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Render

Returns a new instance of Render.



8
9
10
11
12
13
14
15
16
# File 'lib/statikaj/render.rb', line 8

def initialize(source, options)
  @source = source
  @article = options.delete(:article) if options[:article]
  @articles = options.delete(:articles) if options[:articles]
  @type = options.fetch(:type, :html)
  if options[:page] && @type == :html
    render_page(options.delete(:page))
  end
end

Instance Attribute Details

#articlesObject

Returns the value of attribute articles.



6
7
8
# File 'lib/statikaj/render.rb', line 6

def articles
  @articles
end

#categoryObject

Returns the value of attribute category.



6
7
8
# File 'lib/statikaj/render.rb', line 6

def category
  @category
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/statikaj/render.rb', line 6

def description
  @description
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/statikaj/render.rb', line 6

def title
  @title
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/statikaj/render.rb', line 6

def url
  @url
end

Instance Method Details

#article {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
# File 'lib/statikaj/render.rb', line 18

def article(&blk)
  yield self
  to_html do
    @article.render(@source)
  end
end

#page {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
# File 'lib/statikaj/render.rb', line 25

def page(&blk)
  yield self
  send("to_#{@type}"){ @page }
end