1##
2# An Indented Paragraph of text
3
4class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
5
6  ##
7  # The indent in number of spaces
8
9  attr_reader :indent
10
11  ##
12  # Creates a new IndentedParagraph containing +parts+ indented with +indent+
13  # spaces
14
15  def initialize indent, *parts
16    @indent = indent
17
18    super(*parts)
19  end
20
21  def == other # :nodoc:
22    super and indent == other.indent
23  end
24
25  ##
26  # Calls #accept_indented_paragraph on +visitor+
27
28  def accept visitor
29    visitor.accept_indented_paragraph self
30  end
31
32  ##
33  # Joins the raw paragraph text and converts inline HardBreaks to the
34  # +hard_break+ text followed by the indent.
35
36  def text hard_break = nil
37    @parts.map do |part|
38      if RDoc::Markup::HardBreak === part then
39        '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
40      else
41        part
42      end
43    end.join
44  end
45
46end
47
48