Sha256: 48b558c24646b2fb2899252109c668d0c3b0e6fbe841b83fe1e725a26906e5d4
Contents?: true
Size: 627 Bytes
Versions: 14
Compression:
Stored size: 627 Bytes
Contents
require 'terminal-table' class Ld::Print def initialize models @models = models end def self.p models,fields t = Terminal::Table.new t.title = models.first.class.to_s fields = (fields.class == Array ? fields : fields.split(',')).map{|f| f.rstrip.lstrip} t.headings = fields models.map { |model| fields.map { |field| value = model.send field value = value.strftime("%Y/%m/%d %H:%M:%S") if [Date, Time, DateTime, ActiveSupport::TimeWithZone].include? value.class value } }#.sort{|a,b| a[2] <=> b[2]} .each{|row| t.add_row row} puts t end end
Version data entries
14 entries across 14 versions & 1 rubygems