Class: HtmlRender
- Inherits:
-
Object
- Object
- HtmlRender
- Defined in:
- lib/almirah/html_render.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#htmlRows ⇒ Object
Returns the value of attribute htmlRows.
-
#outputFile ⇒ Object
Returns the value of attribute outputFile.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(document, template, outputFile) ⇒ HtmlRender
constructor
A new instance of HtmlRender.
- #render ⇒ Object
- #saveRenderToFile ⇒ Object
Constructor Details
#initialize(document, template, outputFile) ⇒ HtmlRender
Returns a new instance of HtmlRender.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/almirah/html_render.rb', line 14 def initialize(document, template, outputFile) @template = template @outputFile = outputFile @htmlRows = Array.new @document = document self.render() self.saveRenderToFile() end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
12 13 14 |
# File 'lib/almirah/html_render.rb', line 12 def document @document end |
#htmlRows ⇒ Object
Returns the value of attribute htmlRows.
10 11 12 |
# File 'lib/almirah/html_render.rb', line 10 def htmlRows @htmlRows end |
#outputFile ⇒ Object
Returns the value of attribute outputFile.
11 12 13 |
# File 'lib/almirah/html_render.rb', line 11 def outputFile @outputFile end |
#template ⇒ Object
Returns the value of attribute template.
9 10 11 |
# File 'lib/almirah/html_render.rb', line 9 def template @template end |
Instance Method Details
#render ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/almirah/html_render.rb', line 25 def render() self.htmlRows.append('') self.document.docItems.each do |item| a = item.to_html self.htmlRows.append a end end |
#saveRenderToFile ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/almirah/html_render.rb', line 34 def saveRenderToFile() file = File.open( self.template ) file_data = file.readlines file.close file = File.open( self.outputFile, "w" ) file_data.each do |s| if s.include?('{{CONTENT}}') self.htmlRows.each do |r| file.puts r end else file.puts s end end file.close end |