Class: RDoc::Markup::Table

Inherits:
Element
  • 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

: (Array, Array, Array) -> void



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

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

Instance Attribute Details

#alignObject

Alignments of each column : Array



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

def align
  @align
end

#bodyObject

Body texts of each column : Array



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

def body
  @body
end

#headerObject

Headers of each column : Array



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

def header
  @header
end

Instance Method Details

#==(other) ⇒ Object

: (Object) -> bool



25
26
27
28
# 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) ⇒ Object

: (untyped) -> void



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

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

#pretty_print(q) ⇒ Object

: (untyped) -> String



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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