Class: Linker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLinker

Returns a new instance of Linker.



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

def initialize()
    @field = "field"
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



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

def field
  @field
end

Instance Method Details



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/almirah/linker.rb', line 12

def link(doc_A, doc_B)

    if doc_A.key == doc_B.up_link_key
        top_document = doc_A
        bottom_document = doc_B
    elsif doc_B.key == doc_A.up_link_key
        top_document = doc_B
        bottom_document = doc_A
    else
        puts "No Links"
        return # no links

    end

    bottom_document.controlledParagraphs.each do |item|

        if top_document.dictionary.has_key?(item.up_link.to_s)

            topItem = top_document.dictionary[item.up_link.to_s]
            
            unless topItem.down_links
                topItem.down_links = Array.new
            end
            topItem.down_links.append(item)

            #if tmp = /^([a-zA-Z]+)[-]\d+/.match(item.id)

            #    top_document.downlinkKey = tmp[1].upcase

            #end

        end
    end
end