Sha256: 1e035ef1e33c8722975467c02b9eb264a62d66f21bf8701a05d99688f024d80b
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true class Tabled class Template class Row # | Luke Skywalker 172 male | def self.render(row, columns_width, _is_framed) row[0..-2].map.with_index do |column, index| spaces = ' ' * (columns_width[index] - column.to_s.size) column.to_s + spaces end.join end end class Titles # ------------------------------------ # | Name Height Gender | # ------------------------------------ def self.render(row, columns_width, _is_framed) row.map.with_index do |column, index| spaces = ' ' * (columns_width[index] - column.to_s.size) column.to_s + spaces end.join end end class RowFooter def self.render(row, columns_width, _is_framed) return nil unless row.last.fetch(:footer, false) footer = row.last.fetch(:footer) required_spaces = columns_width.sum - footer.size footer + (' ' * required_spaces) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tabled-0.0.5 | lib/template.rb |
tabled-0.0.4 | lib/template.rb |
tabled-0.0.3 | lib/template.rb |