1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/rdoc/markup/paragraph.rb
drbrain 46580b5147 Import RDoc 2.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-01 07:45:16 +00:00

66 lines
951 B
Ruby

##
# A Paragraph of text
class RDoc::Markup::Paragraph
##
# The component parts of the list
attr_reader :parts
##
# Creates a new Paragraph containing +parts+
def initialize *parts
@parts = []
@parts.push(*parts)
end
##
# Appends +text+ to the Paragraph
def << text
@parts << text
end
def == other # :nodoc:
self.class == other.class and text == other.text
end
def accept visitor
visitor.accept_paragraph self
end
##
# Appends +other+'s parts into this Paragraph
def merge other
@parts.push(*other.parts)
end
def pretty_print q # :nodoc:
self.class.name =~ /.*::(\w{4})/i
q.group 2, "[#{$1.downcase}: ", ']' do
q.seplist @parts do |part|
q.pp part
end
end
end
##
# Appends +texts+ onto this Paragraph
def push *texts
self.parts.push(*texts)
end
##
# The text of this paragraph
def text
@parts.join ' '
end
end