Class: BaseDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/almirah/doc_types/base_document.rb

Direct Known Subclasses

Coverage, Index, Protocol, Specification, Traceability

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headingsObject

Returns the value of attribute headings.



6
7
8
# File 'lib/almirah/doc_types/base_document.rb', line 6

def headings
  @headings
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/almirah/doc_types/base_document.rb', line 8

def id
  @id
end

#itemsObject

Returns the value of attribute items.



5
6
7
# File 'lib/almirah/doc_types/base_document.rb', line 5

def items
  @items
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/almirah/doc_types/base_document.rb', line 4

def path
  @path
end

#titleObject

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.expand_path './../../..', 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