123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::Table

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Element
Instance Chain:
self, Element
Inherits: RDoc::Markup::Element
Defined in: lib/rdoc/markup/table.rb

Overview

A section of table

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Element - Inherited

#accept

: (untyped) -> void.

#pretty_print

: (PP) -> void.

Constructor Details

.new(header, align, body) ⇒ Table

: (Array, Array, Array) -> void

[ GitHub ]

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

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

Instance Attribute Details

#align (rw)

Alignments of each column : Array

[ GitHub ]

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

attr_accessor :align

#body (rw)

Body texts of each column : Array

[ GitHub ]

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

attr_accessor :body

#header (rw)

Headers of each column : Array

[ GitHub ]

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

attr_accessor :header

Instance Method Details

#==(other)

: (Object) -> bool

[ GitHub ]

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

def ==(other)
  self.class == other.class && @header == other.header &&
    @align == other.align && @body == other.body
end

#accept(visitor)

: (untyped) -> void

[ GitHub ]

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

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

#pretty_print(q)

: (untyped) -> String

[ GitHub ]

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

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