class Timebomb::CLIReport
Constants
- EXPLODED_CHARACTER
- RED_COLOR_CODE
- UNEXPLODED_CHARACTER
Attributes
suite[R]
Public Class Methods
new(suite)
click to toggle source
# File lib/timebomb.rb, line 116 def initialize(suite) @suite = suite end
Public Instance Methods
print(out)
click to toggle source
# File lib/timebomb.rb, line 120 def print(out) out.puts "Detected #{suite.timebombs.count} timebombs" suite.timebombs.each do |tb| out.puts row " #{explosion_symbol(tb)} ", format_date(tb.date), days_until(tb), tb.title end if suite.has_exploded? out.puts "#{suite.exploded_timebombs.count} timebombs have exploded!" end end
Private Instance Methods
days_until(tb)
click to toggle source
# File lib/timebomb.rb, line 135 def days_until(tb) days = tb.days_difference if days < 0 "Exploded #{-days.to_i} days ago" else "Explodes in #{days.to_i} days" end end
explosion_symbol(tb)
click to toggle source
# File lib/timebomb.rb, line 144 def explosion_symbol(tb) tb.has_exploded? ? EXPLODED_CHARACTER : UNEXPLODED_CHARACTER end
format_date(date)
click to toggle source
# File lib/timebomb.rb, line 148 def format_date(date) date.strftime "%b %e, %Y" end
row(*columns)
click to toggle source
# File lib/timebomb.rb, line 131 def row(*columns) columns.join("\t") end