Class: RD::ReferenceResolver

### Home Classes Methods

### In Files

- lib/rd/reference-resolver.rb

### Parent

Object

### Methods

- ::new
- #each
- #each_label
- #get_anchor
- #get_label_num
- #label2str
- #make_rbl_file
- #refer
- #refer_element
- #refer_external_file
- #referent_of_label

### Included Modules

- Enumerable

### Files

- post-install

### Class/Module Index

Quicksearch

- RD
- RD::AutoLabel
- RD::BlockElement
- RD::Code
- RD::ComplexListItem
- RD::DescList
- RD::DescListItem
- RD::DescListItem::Term
- RD::DocumentElement
- RD::DocumentStructure
- RD::Element
- RD::ElementRelationship
- RD::Emphasis
- RD::EnumList
- RD::EnumListItem
- RD::Filter
- RD::Filter::FileInclude
- RD::Footnote
- RD::Headline
- RD::Include
- RD::Index
- RD::InlineElement
- RD::InlineIncludable
- RD::ItemList
- RD::ItemListItem
- RD::Keyboard
- RD::LabelComposable
- RD::LabeledElement
- RD::List
- RD::ListItem
- RD::ListItemComposable
- RD::MethodList
- RD::MethodListItem
- RD::MethodListItem::Term
- RD::MethodParse
- RD::NonterminalElement
- RD::NonterminalInline
- RD::OutputFormatVisitor
- RD::ParserUtility
- RD::Part
- RD::RBLFile
- RD::RBLSuite
- RD::RD2HTMLExtVisitor
- RD::RD2HTMLExtVisitor::EnableBr
- RD::RD2HTMLExtVisitor::HeadElement
- RD::RD2HTMLExtVisitor::HeadLineTitle
- RD::RD2HTMLExtVisitor::HeadlineSecno
- RD::RD2HTMLExtVisitor::NativeInline
- RD::RD2HTMLExtVisitor::RefExtension
- RD::RD2HTMLVisitor
- RD::RD2MANVisitor
- RD::RD2RDOVisitor
- RD::RD2RMIVisitor
- RD::RDElement
- RD::RDInlineParser
- RD::RDParser
- RD::RDTree
- RD::RDVisitor
- RD::Reference
- RD::Reference::Label
- RD::Reference::RDLabel
- RD::Reference::TemporaryLabel
- RD::Reference::URL
- RD::ReferenceResolver
- RD::SearchFile
- RD::StringElement
- RD::TerminalElement
- RD::TerminalInline
- RD::TextBlock
- RD::Tree
- RD::Var
- RD::Verb
- RD::Verbatim
- RD::Version
- RD::Visitor
- Array

No matching classes.

# RD::ReferenceResolver

### Attributes

label_prefix[R]
labels[R]
rbl_suite[R]

### Public Class Methods

new(tree, prefix = "label:") click to toggle source

    # File lib/rd/reference-resolver.rb, line 15
    def initialize(tree, prefix = "label:")
      init_labels(tree)
      @label_prefix = prefix
      @rbl_suite = RBLSuite.new(tree.include_path)
    end

### Public Instance Methods

each() click to toggle source
Alias for: each_label
each_label() click to toggle source

    # File lib/rd/reference-resolver.rb, line 43
    def each_label
      tmp = []
      labels.each_value do |i|
        i.each do |j|
          tmp.push(j)
        end
      end
      tmp.sort{|i,j| i[1] <=> j[1]}.each do |i|
        yield(i[0])
      end
    end

Also aliased as: each
get_anchor(element) click to toggle source

    # File lib/rd/reference-resolver.rb, line 88
    def get_anchor(element)
      if num = get_label_num(element)
        num2anchor(num)
      end
    end

get_label_num(element) click to toggle source

    # File lib/rd/reference-resolver.rb, line 82
    def get_label_num(element)
      entry = labels[element.to_label].find{|i| i[0] == element }
      return nil unless entry
      entry[1]
    end

label2str(label) click to toggle source

    # File lib/rd/reference-resolver.rb, line 99
    def label2str(label)
      case label
      when String
        label
      when Element, Reference::RDLabel
        label.to_label
      else
        raise ArgumentError, "can't extract Label from #{label}."
      end
    end

make_rbl_file(filename) click to toggle source

    # File lib/rd/reference-resolver.rb, line 110
    def make_rbl_file(filename)
      RBLFile.create_rbl_file(filename, self)
    end

refer(label) click to toggle source

    # File lib/rd/reference-resolver.rb, line 67
    def refer(label)
      matched = labels[label2str(label)]
      return nil unless matched
      num2anchor(matched[0][1])
    end

refer_element(label) click to toggle source

    # File lib/rd/reference-resolver.rb, line 73
    def refer_element(label)
      labels.fetch(label2str(label), []).collect{|i| i[0] }
    end

refer_external_file(label) click to toggle source

    # File lib/rd/reference-resolver.rb, line 77
    def refer_external_file(label)
      label = label.label if label.is_a? Reference
      rbl_suite.refer(label.element_label, label.filename)
    end

referent_of_label(label) click to toggle source

    # File lib/rd/reference-resolver.rb, line 56
    def referent_of_label(label)
      label = label.label if label.is_a? Reference
      if label.filename
        refer_external_file(label)
      else
        anchor = refer(label)
        return nil unless anchor
        [nil, anchor]
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.