Class: Wlog::LogEntry

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/wlog/domain/log_entry.rb

Overview

Active Record Domain object for a log entry

Instance Method Summary collapse

Instance Method Details

#to_sObject

Print things nicely formmated no more than 80 cars (well, unless you stick the time in the end which is not counted for).



25
26
27
28
29
30
31
32
# File 'lib/wlog/domain/log_entry.rb', line 25

def to_s
  str    = "[#{id}] "
  tmp    = "#{description} [#{created_at.strftime("%H:%M:%S")}]"
  desc   = Helpers.break_string(tmp,80)
  indent = " " * (id.to_s.split('').count + 5)
  desc.gsub!(/#{$/}/, "#{$/}#{indent}")
  str.concat(desc)
str end