class RenderAsMarkdown::Column

Attributes

rows[RW]
title[RW]
width[RW]

Public Class Methods

new(title) click to toggle source
# File lib/render-as-markdown/table.rb, line 64
def initialize title
  @rows = []
  @title = title.to_s
  @width = [@title.length, 1].max
end

Public Instance Methods

add_row(string) click to toggle source
# File lib/render-as-markdown/table.rb, line 82
def add_row string
  string ||= ''
  @rows << string
  update_width string.to_s.length
end
render_line() click to toggle source
# File lib/render-as-markdown/table.rb, line 74
def render_line
  '-'.ljust @width, '-'
end
render_row(row_number) click to toggle source
# File lib/render-as-markdown/table.rb, line 78
def render_row row_number
  @rows[row_number].ljust @width
end
render_title() click to toggle source
# File lib/render-as-markdown/table.rb, line 70
def render_title
  @title.ljust @width
end
update_width(length) click to toggle source
# File lib/render-as-markdown/table.rb, line 88
def update_width length
  @width = length if @width < length
end