Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'header_separator' option for Style #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/terminal-table/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,13 @@ def border_top=(val) ; @border.top = val ; end
def border_bottom=(val) ; @border.bottom = val ; end
def border_left=(val) ; @border.left = val ; end
def border_right=(val) ; @border.right = val ; end
def header_separator=(val) ; @header_separator = val ; end

def border_top ; @border.top ; end
def border_bottom ; @border.bottom ; end
def border_left ; @border.left ; end
def border_right ; @border.right ; end
def header_separator ; @header_separator ; end


attr_accessor :padding_left
Expand Down
9 changes: 7 additions & 2 deletions lib/terminal-table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def initialize options = {}, &block
@headings = []
@rows = []
@column_widths = []
self.style = options.fetch :style, {}
style_opts = options.fetch :style, {}
style_opts[:header_separator] = true unless style_opts.key?(:header_separator)

self.style = style_opts
self.headings = options.fetch :headings, []
self.rows = options.fetch :rows, []
self.title = options.fetch :title, nil
Expand Down Expand Up @@ -133,7 +136,9 @@ def elaborate_rows
@headings.each do |row|
unless row.cells.empty?
buffer << row
buffer << Separator.new(self, border_type: :double, implicit: true)
if style.header_separator
buffer << Separator.new(self, border_type: :double, implicit: true)
end
end
end
if style.all_separators
Expand Down