Class: Rack::Blogengine::Document
- Inherits:
-
Object
- Object
- Rack::Blogengine::Document
- Defined in:
- lib/rack/blogengine/document.rb
Overview
Document Class Contains attributes path, html, title, date
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#html ⇒ Object
Returns the value of attribute html.
-
#path ⇒ Object
Returns the value of attribute path.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#exec_content_operator(documents, target) ⇒ String
Executes Content Operators and returns modified html.
-
#to_hash ⇒ Hash
Converts Rack::Blogengine::Docuemnt to Hash.
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
10 11 12 |
# File 'lib/rack/blogengine/document.rb', line 10 def date @date end |
#html ⇒ Object
Returns the value of attribute html.
10 11 12 |
# File 'lib/rack/blogengine/document.rb', line 10 def html @html end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/rack/blogengine/document.rb', line 10 def path @path end |
#title ⇒ Object
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
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_hash ⇒ Hash
Converts Rack::Blogengine::Docuemnt to Hash
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 |