Class: RDoc::Markup::IndentedParagraph

Inherits:
Markup::Raw
  • Object
show all
Defined in:
lib/rdoc/markup/indented_paragraph.rb

Overview

An Indented Paragraph of text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indent, *parts) ⇒ IndentedParagraph

Creates a new IndentedParagraph containing parts indented with indent spaces



18
19
20
21
22
# File 'lib/rdoc/markup/indented_paragraph.rb', line 18

def initialize(indent, *parts)
  @indent = indent

  super(*parts)
end

Instance Attribute Details

#indent ⇒ Object (readonly)

The indent in number of spaces



12
13
14
# File 'lib/rdoc/markup/indented_paragraph.rb', line 12

def indent
  @indent
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



24
25
26
# File 'lib/rdoc/markup/indented_paragraph.rb', line 24

def ==(other) # :nodoc:
  super and indent == other.indent
end

#accept(visitor) ⇒ Object

Calls #accept_indented_paragraph on visitor



31
32
33
# File 'lib/rdoc/markup/indented_paragraph.rb', line 31

def accept(visitor)
  visitor.accept_indented_paragraph self
end

#text(hard_break = nil) ⇒ Object

Joins the raw paragraph text and converts inline HardBreaks to the hard_break text followed by the indent.



39
40
41
42
43
44
45
46
47
# File 'lib/rdoc/markup/indented_paragraph.rb', line 39

def text(hard_break = nil)
  @parts.map do |part|
    if Markup::HardBreak === part
      '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
    else
      part
    end
  end.join
end