Class: BaseDocument
- Inherits:
-
Object
- Object
- BaseDocument
- Defined in:
- lib/almirah/doc_types/base_document.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#headings ⇒ Object
Returns the value of attribute headings.
-
#id ⇒ Object
Returns the value of attribute id.
-
#items ⇒ Object
Returns the value of attribute items.
-
#path ⇒ Object
Returns the value of attribute path.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(fele_path) ⇒ BaseDocument
constructor
A new instance of BaseDocument.
- #save_html_to_file(html_rows, nav_pane, output_file_path) ⇒ Object
Constructor Details
#initialize(fele_path) ⇒ BaseDocument
Returns a new instance of BaseDocument.
10 11 12 13 14 15 16 17 |
# File 'lib/almirah/doc_types/base_document.rb', line 10 def initialize(fele_path) @path = fele_path @items = Array.new @headings = Array.new @title = "" @id = "" end |
Instance Attribute Details
#headings ⇒ Object
Returns the value of attribute headings.
6 7 8 |
# File 'lib/almirah/doc_types/base_document.rb', line 6 def headings @headings end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/almirah/doc_types/base_document.rb', line 8 def id @id end |
#items ⇒ Object
Returns the value of attribute items.
5 6 7 |
# File 'lib/almirah/doc_types/base_document.rb', line 5 def items @items end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/almirah/doc_types/base_document.rb', line 4 def path @path end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/almirah/doc_types/base_document.rb', line 7 def title @title end |
Instance Method Details
#save_html_to_file(html_rows, nav_pane, output_file_path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/almirah/doc_types/base_document.rb', line 19 def save_html_to_file html_rows, nav_pane, output_file_path gem_root = File. './../../..', File.dirname(__FILE__) template_file = gem_root + "/lib/almirah/templates/page.html" file = File.open( template_file ) file_data = file.readlines file.close if @id == 'index' output_file_path += "#{@id}.html" else output_file_path += "#{@id}/#{@id}.html" end file = File.open( output_file_path, "w" ) file_data.each do |s| if s.include?('{{CONTENT}}') html_rows.each do |r| file.puts r end elsif s.include?('{{NAV_PANE}}') if nav_pane file.puts nav_pane.to_html end elsif s.include?('{{DOCUMENT_TITLE}}') file.puts s.gsub! '{{DOCUMENT_TITLE}}', @title else file.puts s end end file.close end |