Sha256: ab7530d3b86b0b2f9358135f057a87b217bc381fc5f4de248802f2dd9c370589

Contents?: true

Size: 1.12 KB

Versions: 16

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
##
# A section of table

class RDoc::Markup::Table
  # headers of each column
  attr_accessor :header

  # alignments of each column
  attr_accessor :align

  # body texts of each column
  attr_accessor :body

  # Creates new instance
  def initialize header, align, body
    @header, @align, @body = header, align, body
  end

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

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

  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
end

Version data entries

16 entries across 14 versions & 6 rubygems

Version Path
rdoc-6.12.0 lib/rdoc/markup/table.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/rdoc-6.11.0/lib/rdoc/markup/table.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/rdoc-6.7.0/lib/rdoc/markup/table.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rdoc-6.10.0/lib/rdoc/markup/table.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rdoc-6.8.1/lib/rdoc/markup/table.rb
rdoc-6.11.0 lib/rdoc/markup/table.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rdoc-6.7.0/lib/rdoc/markup/table.rb
rdoc-6.10.0 lib/rdoc/markup/table.rb
rdoc-6.9.1 lib/rdoc/markup/table.rb
rdoc-6.9.0 lib/rdoc/markup/table.rb
rdoc-6.8.1 lib/rdoc/markup/table.rb
rdoc-6.8.0 lib/rdoc/markup/table.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rdoc-6.7.0/lib/rdoc/markup/table.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rdoc-6.7.0/lib/rdoc/markup/table.rb
rdoc-6.6.3.1 lib/rdoc/markup/table.rb
rdoc-6.6.2 lib/rdoc/markup/table.rb