123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::Verbatim

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Raw
Instance Chain:
self, Raw
Inherits: RDoc::Markup::Raw
Defined in: lib/rdoc/markup/verbatim.rb

Overview

A section of verbatim text

Class Method Summary

Raw - Inherited

.new

Creates a new Raw containing parts

Instance Attribute Summary

Raw - Inherited

#parts

The component parts of the list.

Instance Method Summary

Raw - Inherited

#<<

Appends #text

#accept

Calls #accept_raw+ on visitor

#merge

Appends other's parts.

#push

Appends texts onto this Paragraph.

#text

The raw text.

Constructor Details

This class inherits a constructor from RDoc::Markup::Raw

Instance Attribute Details

#format (rw)

Format of this verbatim section

[ GitHub ]

  
# File 'lib/rdoc/markup/verbatim.rb', line 9

attr_accessor :format

#ruby?Boolean (readonly)

Is this verbatim section Ruby code?

[ GitHub ]

  
# File 'lib/rdoc/markup/verbatim.rb', line 70

def ruby?
  @format ||= nil # TODO for older ri data, switch the tree to marshal_dump
  @format == :ruby
end

Instance Method Details

#accept(visitor)

Calls #accept_verbatim on visitor

[ GitHub ]

  
# File 'lib/rdoc/markup/verbatim.rb', line 24

def accept visitor
  visitor.accept_verbatim self
end

#normalize

Collapses 3+ newlines into two newlines

[ GitHub ]

  
# File 'lib/rdoc/markup/verbatim.rb', line 31

def normalize
  parts = []

  newlines = 0

  @parts.each do |part|
    case part
    when /^\s*\n/ then
      newlines += 1
      parts << part if newlines == 1
    else
      newlines = 0
      parts << part
    end
  end

  parts.pop if parts.last =~ /\A\r?\n\z/

  @parts = parts
end

#text

The text of the section

[ GitHub ]

  
# File 'lib/rdoc/markup/verbatim.rb', line 78

def text
  @parts.join
end