Class: RDoc::Markup::Verbatim
Overview
A section of verbatim text
Instance Attribute Summary
Attributes inherited from Raw
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
Calls #accept_verbatim on
visitor
. -
#normalize ⇒ Object
Collapses 3+ newlines into two newlines.
-
#text ⇒ Object
The text of the section.
Methods inherited from Raw
#<<, #==, #initialize, #merge, #pretty_print, #push
Constructor Details
This class inherits a constructor from RDoc::Markup::Raw
Instance Method Details
#accept(visitor) ⇒ Object
Calls #accept_verbatim on visitor
9 10 11 |
# File 'lib/rdoc/markup/verbatim.rb', line 9 def accept visitor visitor.accept_verbatim self end |
#normalize ⇒ Object
Collapses 3+ newlines into two newlines
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rdoc/markup/verbatim.rb', line 16 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 ⇒ Object
The text of the section
40 41 42 |
# File 'lib/rdoc/markup/verbatim.rb', line 40 def text @parts.join end |