Class: Rack::Blogengine::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/blogengine/document.rb

Overview

Document Class Contains attributes path, html, title, date

Author:

  • benny

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dateObject

Returns the value of attribute date.



10
11
12
# File 'lib/rack/blogengine/document.rb', line 10

def date
  @date
end

#htmlObject

Returns the value of attribute html.



10
11
12
# File 'lib/rack/blogengine/document.rb', line 10

def html
  @html
end

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/rack/blogengine/document.rb', line 10

def path
  @path
end

#titleObject

Returns the value of attribute title.



10
11
12
# File 'lib/rack/blogengine/document.rb', line 10

def title
  @title
end

Instance Method Details

#exec_content_operator(documents, target) ⇒ String

Executes Content Operators and returns modified html

Parameters:

  • documents (Array)
    Array of Documents available in operators
  • target (String)
    Target for executing Operator from Targetfolder

Returns:

  • (String)

    @html [Sets @html to modified html from operator]



29
30
31
32
33
34
35
36
37
# File 'lib/rack/blogengine/document.rb', line 29

def exec_content_operator(documents, target)
  @html.scan(/\{\%(.*?)\%\}/).each do |contentoperator|
    contentoperator = contentoperator[0].strip.to_sym
    operator = Operator.new(target)
    operatorhtml = operator.send(contentoperator, documents, @html)

    @html['{% ' + contentoperator.to_s + ' %}'] = operatorhtml
  end
end

#to_hashHash

Converts Rack::Blogengine::Docuemnt to Hash

Returns:

  • (Hash)

    DocumentHashed [Document in Hash Presentation contains :path and :html]



14
15
16
17
18
19
20
21
22
# File 'lib/rack/blogengine/document.rb', line 14

def to_hash
  hash = {}
  instance_variables.each do |var|
    unless var.to_s == '@title' || var.to_s == '@date'
      hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
    end
  end
  hash
end