Class: RDoc::Markup::Table

Inherits:
Object show all
Defined in:
lib/rdoc/markup/table.rb

Overview

A section of table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, align, body) ⇒ Table

Creates new instance



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

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

Instance Attribute Details

#alignObject

alignments of each column



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

def align
  @align
end

#bodyObject

body texts of each column



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

def body
  @body
end

#headerObject

headers of each column



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

def header
  @header
end

Instance Method Details

#==(other) ⇒ Object

:stopdoc:



21
22
23
24
25
26
# 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) ⇒ Object



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

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

#pretty_print(q) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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