diff --git a/lib/rdoc/markup/indented_paragraph.rb b/lib/rdoc/markup/indented_paragraph.rb index c218501ce6..a5b0e1aa23 100644 --- a/lib/rdoc/markup/indented_paragraph.rb +++ b/lib/rdoc/markup/indented_paragraph.rb @@ -1,47 +1,44 @@ # frozen_string_literal: true -## -# An Indented Paragraph of text -class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw +module RDoc + class Markup + # An Indented Paragraph of text + class IndentedParagraph < Raw + # The indent in number of spaces + #: Integer + attr_reader :indent - ## - # The indent in number of spaces + # Creates a new IndentedParagraph containing +parts+ indented with +indent+ spaces + #: (Integer, *String) -> void + def initialize(indent, *parts) + @indent = indent - attr_reader :indent - - ## - # Creates a new IndentedParagraph containing +parts+ indented with +indent+ - # spaces - - def initialize indent, *parts - @indent = indent - - super(*parts) - end - - def ==(other) # :nodoc: - super and indent == other.indent - end - - ## - # Calls #accept_indented_paragraph on +visitor+ + super(*parts) + end - def accept(visitor) - visitor.accept_indented_paragraph self - end + #: (top) -> bool + def ==(other) # :nodoc: + super && @indent == other.indent + end - ## - # Joins the raw paragraph text and converts inline HardBreaks to the - # +hard_break+ text followed by the indent. + # Calls #accept_indented_paragraph on +visitor+ + # @override + #: (untyped) -> void + def accept(visitor) + visitor.accept_indented_paragraph(self) + end - def text(hard_break = nil) - @parts.map do |part| - if RDoc::Markup::HardBreak === part then - '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break - else - part + # Joins the raw paragraph text and converts inline HardBreaks to the +hard_break+ text followed by the indent. + #: (?String) -> String + def text(hard_break = nil) + @parts.map do |part| + if HardBreak === part then + '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break + else + part + end + end.join end - end.join + end end - end