Class: RD::RBLFile

### Home Classes Methods

### In Files

- lib/rd/rbl-file.rb

### Parent

Object

### Methods

- ::basename
- ::create_rbl_file
- ::labels_to_string
- ::new
- ::rbl_file_path
- #load_rbl_file
- #parse_line
- #refer
- #string_to_labels

### Included Modules

- RD::SearchFile

### 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::RBLFile

### Constants

SUFFIX

### Attributes

filename[R]
labels[R]

### Public Class Methods

basename(path) click to toggle source

    # File lib/rd/rbl-file.rb, line 26
    def RBLFile.basename(path)
      if /\.(rd|rb)$/ === path
        $`
      else
        path
      end
    end

create_rbl_file(filename, resolver) click to toggle source

    # File lib/rd/rbl-file.rb, line 16
    def RBLFile.create_rbl_file(filename, resolver)
      file = File.open(RBLFile.rbl_file_path(filename), "w")
      file.print(RBLFile.labels_to_string(resolver))
      file.close
    end

labels_to_string(resolver) click to toggle source

    # File lib/rd/rbl-file.rb, line 34
    def RBLFile.labels_to_string(resolver)
      (resolver.collect do |i|
         i.to_label + " => " + resolver.get_anchor(i)
       end).join("\n")
    end

new(filename) click to toggle source

    # File lib/rd/rbl-file.rb, line 11
    def initialize(filename)
      @filename = RBLFile.basename(filename)
      @labels = []
    end

rbl_file_path(filename) click to toggle source

    # File lib/rd/rbl-file.rb, line 22
    def RBLFile.rbl_file_path(filename)
      basename(filename) + "." + SUFFIX
    end

### Public Instance Methods

load_rbl_file(search_paths) click to toggle source

    # File lib/rd/rbl-file.rb, line 40
    def load_rbl_file(search_paths)
      f = search_file(@filename, search_paths, [SUFFIX])
      raise "RBLFile not found." unless f
      src = File.readlines(f).join("")
      @labels = string_to_labels(src)
    end

parse_line(src) click to toggle source

    # File lib/rd/rbl-file.rb, line 55
    def parse_line(src)
      col = src.rindex("=>")
      raise "RBL file parse error." unless col
      label = src[0 .. col - 1].strip
      anchor = src[col + 2 .. -1].strip
      [label, anchor]
    end

refer(label) click to toggle source

    # File lib/rd/rbl-file.rb, line 63
    def refer(label)
      label = @labels.find{|i| i[0] == label}
      return nil unless label
      label[1]
    end

string_to_labels(src) click to toggle source

    # File lib/rd/rbl-file.rb, line 47
    def string_to_labels(src)
      labels = []
      src.each_line do |i|
        labels << parse_line(i)
      end
      labels
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.