123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::Table

Relationships & Source Files
Inherits: Object
Defined in: lib/rdoc/markup/table.rb

Overview

A section of table

Class Method Summary

Instance Attribute Summary

  • #align rw

    alignments of each column.

  • #body rw

    body texts of each column.

  • #header rw

    headers of each column.

Instance Method Summary

Constructor Details

.new(header, align, body) ⇒ Table

Creates new instance

[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 16

def initialize header, align, body
  @header, @align, @body = header, align, body
end

Instance Attribute Details

#align (rw)

alignments of each column

[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 10

attr_accessor :align

#body (rw)

body texts of each column

[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 13

attr_accessor :body

#header (rw)

headers of each column

[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 7

attr_accessor :header

Instance Method Details

#==(other)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 21

def == other
  self.class == other.class and
    @header == other.header and
    @align == other.align and
    @body == other.body
end

#accept(visitor)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 28

def accept visitor
  visitor.accept_table @header, @body, @align
end

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/table.rb', line 32

def pretty_print q
  q.group 2, '[Table: ', ']' do
    q.group 2, '[Head: ', ']' do
      q.seplist @header.zip(@align) do |text, align|
        q.pp text
        if align
          q.text ":"
          q.breakable
          q.text align.to_s
        end
      end
    end
    q.breakable
    q.group 2, '[Body: ', ']' do
      q.seplist @body do |body|
        q.group 2, '[', ']' do
          q.seplist body do |text|
            q.pp text
          end
        end
      end
    end
  end
end