Sha256: b0416b90689361440bff7f61336c6e676eb50ee046fb7852d9812efcada524cb

Contents?: true

Size: 951 Bytes

Versions: 7

Compression:

Stored size: 951 Bytes

Contents

##
# 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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rdoc-2.5.6 lib/rdoc/markup/paragraph.rb
rdoc-2.5.5 lib/rdoc/markup/paragraph.rb
rdoc-2.5.4 lib/rdoc/markup/paragraph.rb
rdoc-2.5.3 lib/rdoc/markup/paragraph.rb
rdoc-2.5.2 lib/rdoc/markup/paragraph.rb
rdoc-2.5.1 lib/rdoc/markup/paragraph.rb
rdoc-2.5 lib/rdoc/markup/paragraph.rb