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
- .new(*parts) ⇒ Verbatim constructor Internal use only
Raw - Inherited
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.
- #==(other) Internal use only
- #pretty_print(q) Internal use only
Raw - Inherited
Constructor Details
.new(*parts) ⇒ Verbatim
This method is for internal use only.
# File 'lib/rdoc/markup/verbatim.rb', line 12
def initialize *parts # :nodoc: super @format = nil end
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
#==(other)
This method is for internal use only.
[ GitHub ]
# File 'lib/rdoc/markup/verbatim.rb', line 18
def == other # :nodoc: super and @format == other.format end
#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
#pretty_print(q)
This method is for internal use only.
[ GitHub ]
# File 'lib/rdoc/markup/verbatim.rb', line 53
def pretty_print q # :nodoc: self.class.name =~ /.*::(\w{1,4})/i q.group 2, "[#{$1.downcase}: ", ']' do if @format then q.text "format: #{@format}" q.breakable end q.seplist @parts do |part| q.pp part end end end
#text
The text of the section
# File 'lib/rdoc/markup/verbatim.rb', line 79
def text @parts.join end