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
Instance Attribute Summary
-
#format
rw
Format of this verbatim section.
-
#ruby? ⇒ Boolean
readonly
Is this verbatim section Ruby code?
Raw - Inherited
#parts | The component parts of the list. |
Instance Method Summary
-
#accept(visitor)
Calls
#accept_verbatim
onvisitor
-
#normalize
Collapses 3+ newlines into two newlines.
-
#text
The text of the section.
Raw - Inherited
Constructor Details
This class inherits a constructor from RDoc::Markup::Raw
Instance Attribute Details
#format (rw)
Format of this verbatim section
# File 'lib/rdoc/markup/verbatim.rb', line 10
attr_accessor :format
#ruby? ⇒ Boolean
(readonly)
Is this verbatim section Ruby code?
# File 'lib/rdoc/markup/verbatim.rb', line 71
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
# File 'lib/rdoc/markup/verbatim.rb', line 25
def accept visitor visitor.accept_verbatim self end
#normalize
Collapses 3+ newlines into two newlines
# File 'lib/rdoc/markup/verbatim.rb', line 32
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
# File 'lib/rdoc/markup/verbatim.rb', line 79
def text @parts.join end