Class: RDoc::Markup::Table

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

Returns a new instance of Table.



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

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

Instance Attribute Details

#alignObject

Returns the value of attribute align.



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

def align
  @align
end

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#headerObject

Returns the value of attribute header.



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

def header
  @header
end

Instance Method Details

#==(other) ⇒ Object



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

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

#accept(visitor) ⇒ Object



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

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

#pretty_print(q) ⇒ Object

:nodoc:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rdoc/markup/table.rb', line 23

def pretty_print q # :nodoc:
  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