Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactoring #render with array buffer
  • Loading branch information
tj committed Dec 18, 2009
1 parent 139cc71 commit 5247f1f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/terminal-table/table.rb
Expand Up @@ -36,15 +36,16 @@ def initialize options = {}, &block
# Render the table.

def render
buffer = separator << "\n"
buffer = [separator, "\n"]
if has_headings?
buffer << render_headings
buffer << "\n#{separator}\n"
buffer << "\n" << separator << "\n"
end
buffer << @rows.map do |row|
render_row(row)
end.join("\n")
buffer << "\n#{separator}\n"
buffer << "\n" << separator << "\n"
buffer.join
end
alias :to_s :render

Expand Down

0 comments on commit 5247f1f

Please sign in to comment.