Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 34 additions & 37 deletions lib/rdoc/markup/indented_paragraph.rb
Original file line number Diff line number Diff line change
@@ -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