Class: Origen::Specs::Doc_Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/specs/doc_resource.rb

Overview

This class is used to store text information to help with documentation processes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selector = {}, table_title = {}, text = {}, options = {}) ⇒ Doc_Resource

Returns a new instance of Doc_Resource.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/origen/specs/doc_resource.rb', line 8

def initialize(selector = {}, table_title = {}, text = {}, options = {})
  @mode = selector[:mode]
  @type = selector[:type]
  @sub_type = selector[:sub_type]
  @audience = selector[:audience]
  @table_title = table_title[:title]
  @note_refs = table_title[:note_refs]
  @exhibit_refs = table_title[:exhibit_refs]
  @before_table = text[:before]
  @after_table = text[:after]
  @doc_options = options
end

Instance Attribute Details

#after_tableObject

Returns the value of attribute after_table.



6
7
8
# File 'lib/origen/specs/doc_resource.rb', line 6

def after_table
  @after_table
end

#audienceObject

Returns the value of attribute audience.



5
6
7
# File 'lib/origen/specs/doc_resource.rb', line 5

def audience
  @audience
end

#before_tableObject

Returns the value of attribute before_table.



6
7
8
# File 'lib/origen/specs/doc_resource.rb', line 6

def before_table
  @before_table
end

#doc_optionsObject

Returns the value of attribute doc_options.



6
7
8
# File 'lib/origen/specs/doc_resource.rb', line 6

def doc_options
  @doc_options
end

#exhibit_refsObject

Returns the value of attribute exhibit_refs.



6
7
8
# File 'lib/origen/specs/doc_resource.rb', line 6

def exhibit_refs
  @exhibit_refs
end

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/origen/specs/doc_resource.rb', line 5

def mode
  @mode
end

#note_refsObject

Returns the value of attribute note_refs.



6
7
8
# File 'lib/origen/specs/doc_resource.rb', line 6

def note_refs
  @note_refs
end

#sub_typeObject

Returns the value of attribute sub_type.



5
6
7
# File 'lib/origen/specs/doc_resource.rb', line 5

def sub_type
  @sub_type
end

#table_titleObject

Returns the value of attribute table_title.



5
6
7
# File 'lib/origen/specs/doc_resource.rb', line 5

def table_title
  @table_title
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/origen/specs/doc_resource.rb', line 5

def type
  @type
end

Instance Method Details

#to_xmlObject



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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/origen/specs/doc_resource.rb', line 21

def to_xml
  tmp = {}
  tmp['mode'] = @mode unless @mode.nil?
  tmp['type'] = @type unless @type.nil?
  tmp['sub_type'] = @sub_type unless @sub_type.nil?
  tmp['audience'] = @audience unless @audience.nil?
  doc_resource_ml = Nokogiri::XML::Builder.new do |xml|
    xml.doc_resource(tmp.each do |t, d|
      "#{t}=\"#{d}\""
    end
                    ) do
      unless @table_title.nil? && @note_refs.size == 0 && @exhibit_refs.size == 0
        unless @note_refs.first.to_s.size == 0
          unless @exhibit_refs.first.to_s.size == 0
            xml.title do
              unless @table_title.nil?
                xml.Text @table_title.to_s
              end
              unless @note_refs.size == 0
                unless @note_refs.first.to_s.size == 0
                  xml.noteRefs do
                    @note_refs = [@note_refs] unless @note_refs.is_a? Array
                    @note_refs.each do |note_ref|
                      unless note_ref.to_s.size == 0
                        xml.noteRef(href: note_ref.to_s)
                      end # unless note_ref.to_s.size == 0
                    end # @note_refs.each do |note_ref|
                  end # xml.noteRefs do
                end # unless @note_refs.first.to_s.size == 0
              end # unless @note_refs.size == 0
              unless @exhibit_refs.size == 0
                unless @exhibit_refs.first.to_s.size == 0
                  xml.exhibitRefs do
                    @exhibit_refs = [@exhibit_refs] unless @exhibit_refs.is_a? Array
                    @exhibit_refs.each do |exhibit_ref|
                      unless exhibit_ref.to_s.size == 0
                        xml.exhibitRef(href: exhibit_ref.to_s)
                      end # unless exhibit_ref.to_s.size == 0
                    end # @exhibit_refs.each do |exhibit_ref|
                  end # xml.exhibitRefs do
                end # unless @exhibit_refs.first.to_s.size == 0
              end # unless @exhibit_refs.size == 0
            end # xml.title.done
          end # unless @exhibit_refs.to_s.size == 0
        end  # unless @note_refs.to_s.size == 0
      end # unless @table_title.nil? && @note_refs.size == 0 && @exhibit_refs.size == 0
      unless @before_table.nil? && @after_table.nil?
        xml.paragraphs do
          unless @before_table.nil?
            if @before_table.is_a? Nokogiri::XML::Node
              xml.before_table @before_table.inner_html
            else
              xml.before_table @before_table
            end
          end
          unless @after_table.nil?
            if @after_table.is_a? Nokogiri::XML::Node
              xml.after_table after_table.inner_html
            else
              xml.after_table @after_table
            end
          end
        end # xml.paragraphs do
      end # unless @before_table.nil? && @after_table.nil?
    end # xml.doc_resource
  end # doc_resource_ml = Nokogiri::
  doc_resource_ml
end